C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

reverse the order of the words

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Matt
Guest





PostPosted: Sun Sep 28, 2003 6:23 pm    Post subject: reverse the order of the words Reply with quote



Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.
Back to top
Ivan Vecerina
Guest





PostPosted: Sun Sep 28, 2003 7:00 pm    Post subject: Re: reverse the order of the words Reply with quote



"Matt" <jrefactors (AT) hotmail (DOT) com> wrote

Quote:
Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.

Matt,
You really are posting a series of classic interview/quizz questions
in comp.lang.c* groups. Some kind of homework ?

For this problem, a classic approach is to reverse the whole sentence,
then reverse the characters of each word. This has the advantage of
being easy to apply in-place.


Cheers,
--
http://ivan.vecerina.com




Back to top
Mike Wahler
Guest





PostPosted: Sun Sep 28, 2003 9:11 pm    Post subject: Re: reverse the order of the words Reply with quote



"Matt" <jrefactors (AT) hotmail (DOT) com> wrote

Quote:
Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.

here homework do not do We.

this read Please:
http://www.slack.net/~shiva/welcome.txt

you Thank,
-Mike




Back to top
Kevin Goodsell
Guest





PostPosted: Sun Sep 28, 2003 9:12 pm    Post subject: Re: reverse the order of the words Reply with quote

Mike Wahler wrote:

Quote:
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...

Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.


here homework do not do We.

this read Please:
http://www.slack.net/~shiva/welcome.txt


Or even this:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


Back to top
Ron Natalie
Guest





PostPosted: Mon Sep 29, 2003 2:15 pm    Post subject: Re: reverse the order of the words Reply with quote


"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote

Quote:
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.

here homework do not do We.

You sound like Master Yoda when you talk like that Smile




Back to top
David Rubin
Guest





PostPosted: Mon Sep 29, 2003 6:08 pm    Post subject: Re: reverse the order of the words Reply with quote

Ron Natalie wrote:
Quote:

"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote

"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.

here homework do not do We.

You sound like Master Yoda when you talk like that Smile

Or a Boy Scout :-)

/david

--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown

Back to top
Mike Wahler
Guest





PostPosted: Mon Sep 29, 2003 6:41 pm    Post subject: Re: [OT] reverse the order of the words Reply with quote


"Ron Natalie" <ron (AT) sensor (DOT) com> wrote

Quote:

"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote

"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
Given an array of characters which form a sentence of words, give an
efficient algorithm to reverse the order of the words (not characters)
in it.

here homework do not do We.

You sound like Master Yoda when you talk like that Smile

It may come as a surprise to many, but I've only seen
the first Star Wars movie, but none of the sequels.
Did this character speak backwards?

-Mike



Back to top
Ron Natalie
Guest





PostPosted: Mon Sep 29, 2003 6:48 pm    Post subject: Re: [OT] reverse the order of the words Reply with quote


"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote


Quote:
here homework do not do We.

You sound like Master Yoda when you talk like that :-)

It may come as a surprise to many, but I've only seen
the first Star Wars movie, but none of the sequels.
Did this character speak backwards?

Not necessarily backwards, but many of his phrasing is reordered
to make him seem more alien.



Back to top
WW
Guest





PostPosted: Mon Sep 29, 2003 6:50 pm    Post subject: Re: [OT] reverse the order of the words Reply with quote

Mike Wahler wrote:
Quote:
here homework do not do We.

You sound like Master Yoda when you talk like that :-)

It may come as a surprise to many, but I've only seen
the first Star Wars movie, but none of the sequels.
Did this character speak backwards?

I backwards did not talk, my apprentice. ;-)

--
WW aka Attila



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.