[algogeeks] reverse a line.

2011-07-21 Thread Saurabh
what is the best way to reverse a line word by word in c or c++???


ex - my name is john
Then after reversing it will be like - john is name my







Regards
Saurabh

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reverse a line.

2011-07-21 Thread mageshthegreat
Push each word into the stack and pop it out at the end of the line.
Sent from BlackBerry® on Airtel

-Original Message-
From: Saurabh saurabh24...@gmail.com
Sender: algogeeks@googlegroups.com
Date: Thu, 21 Jul 2011 17:15:29 
To: algogeeks@googlegroups.com
Reply-To: algogeeks@googlegroups.com
Subject: [algogeeks] reverse a line.

what is the best way to reverse a line word by word in c or c++???


ex - my name is john
Then after reversing it will be like - john is name my







Regards
Saurabh

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reverse a line.

2011-07-21 Thread Tushar Kanta Rath
1st reverse each word in place.then reverse the whole
sentenceit will give the required *answer*

-- 
Tushar Kanta Rath,
Master In Computer Application
MNNIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reverse a line.

2011-07-21 Thread Saurabh
ya it will work but if i dont want any extra space,I have to reverse it with
in that char buffer then how can i it be done..

On Thu, Jul 21, 2011 at 5:17 PM, mageshthegr...@gmail.com wrote:

 ** Push each word into the stack and pop it out at the end of the line.

 Sent from BlackBerry® on Airtel
 --
 *From: * Saurabh saurabh24...@gmail.com
 *Sender: * algogeeks@googlegroups.com
 *Date: *Thu, 21 Jul 2011 17:15:29 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: * algogeeks@googlegroups.com
 *Subject: *[algogeeks] reverse a line.

 what is the best way to reverse a line word by word in c or c++???


 ex - my name is john
 Then after reversing it will be like - john is name my







 Regards
 Saurabh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards  n Luv
Saurabh Badhai

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reverse a line.

2011-07-21 Thread dinesh bansal
Then is need to be done at the cost of performance.

1. First scan the input string till midway and swap the first character with
last and second character with second last and so on.
2. Second scan, swap the word within string the same way.




On Thu, Jul 21, 2011 at 5:36 PM, Saurabh saurabh24...@gmail.com wrote:

 ya it will work but if i dont want any extra space,I have to reverse it
 with in that char buffer then how can i it be done..


 On Thu, Jul 21, 2011 at 5:17 PM, mageshthegr...@gmail.com wrote:

 **Push each word into the stack and pop it out at the end of the line.

 Sent from BlackBerry® on Airtel
 --
 *From: *Saurabh saurabh24...@gmail.com
 *Sender: *algogeeks@googlegroups.com
 *Date: *Thu, 21 Jul 2011 17:15:29 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: *algogeeks@googlegroups.com
 *Subject: *[algogeeks] reverse a line.

 what is the best way to reverse a line word by word in c or c++???


 ex - my name is john
 Then after reversing it will be like - john is name my







 Regards
 Saurabh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards  n Luv
 Saurabh Badhai

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Dinesh Bansal
The Law of Win says, Let's not do it your way or my way; let's do it the
best way.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reverse a line.

2011-07-21 Thread Saurabh
great answer thanks..

On Thu, Jul 21, 2011 at 5:49 PM, dinesh bansal bansal...@gmail.com wrote:

 Then is need to be done at the cost of performance.

 1. First scan the input string till midway and swap the first character
 with last and second character with second last and so on.
 2. Second scan, swap the word within string the same way.




 On Thu, Jul 21, 2011 at 5:36 PM, Saurabh saurabh24...@gmail.com wrote:

 ya it will work but if i dont want any extra space,I have to reverse it
 with in that char buffer then how can i it be done..


 On Thu, Jul 21, 2011 at 5:17 PM, mageshthegr...@gmail.com wrote:

 **Push each word into the stack and pop it out at the end of the line.

 Sent from BlackBerry® on Airtel
 --
 *From: *Saurabh saurabh24...@gmail.com
 *Sender: *algogeeks@googlegroups.com
 *Date: *Thu, 21 Jul 2011 17:15:29 +0530
 *To: *algogeeks@googlegroups.com
 *ReplyTo: *algogeeks@googlegroups.com
 *Subject: *[algogeeks] reverse a line.

 what is the best way to reverse a line word by word in c or c++???


 ex - my name is john
 Then after reversing it will be like - john is name my







 Regards
 Saurabh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards  n Luv
 Saurabh Badhai

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Dinesh Bansal
 The Law of Win says, Let's not do it your way or my way; let's do it the
 best way.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards  n Luv
Saurabh Badhai

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.