reverse the order of the words

Discussion in 'C++' started by Matt, Sep 28, 2003.

  1. Matt

    Matt Guest

    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, Sep 28, 2003
    #1
    1. Advertising

  2. "Matt" <> wrote in message
    news:...
    > 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
     
    Ivan Vecerina, Sep 28, 2003
    #2
    1. Advertising

  3. Matt

    Mike Wahler Guest

    "Matt" <> wrote in message
    news:...
    > 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
     
    Mike Wahler, Sep 28, 2003
    #3
  4. Mike Wahler wrote:

    > "Matt" <> wrote in message
    > news:...
    >
    >>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.
     
    Kevin Goodsell, Sep 28, 2003
    #4
  5. Matt

    Ron Natalie Guest

    "Mike Wahler" <> wrote in message news:X7Idb.7917$...
    > "Matt" <> wrote in message
    > news:...
    > > 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 :)
     
    Ron Natalie, Sep 29, 2003
    #5
  6. Matt

    David Rubin Guest

    Ron Natalie wrote:
    >
    > "Mike Wahler" <> wrote in message news:X7Idb.7917$...
    > > "Matt" <> wrote in message
    > > news:...
    > > > 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 :)


    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
     
    David Rubin, Sep 29, 2003
    #6
  7. Matt

    Mike Wahler Guest

    Re: [OT] reverse the order of the words

    "Ron Natalie" <> wrote in message
    news:3f783e69$0$37004$...
    >
    > "Mike Wahler" <> wrote in message

    news:X7Idb.7917$...
    > > "Matt" <> wrote in message
    > > news:...
    > > > 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 :)


    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
     
    Mike Wahler, Sep 29, 2003
    #7
  8. Matt

    Ron Natalie Guest

    Re: [OT] reverse the order of the words

    "Mike Wahler" <> wrote in message news:q1%db.7944$...

    > > > 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.
     
    Ron Natalie, Sep 29, 2003
    #8
  9. Matt

    WW Guest

    Re: [OT] reverse the order of the words

    Mike Wahler wrote:
    >>> 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
     
    WW, Sep 29, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Strøiman
    Replies:
    1
    Views:
    2,112
    Peter Strøiman
    Aug 23, 2005
  2. Matt
    Replies:
    11
    Views:
    52,482
    satyam000
    Aug 16, 2010
  3. dogbite
    Replies:
    4
    Views:
    705
    osmium
    Oct 10, 2003
  4. Richard Heathfield
    Replies:
    7
    Views:
    381
    Barry Schwarz
    Oct 5, 2003
  5. kirankashyap
    Replies:
    0
    Views:
    942
    kirankashyap
    Aug 28, 2011
Loading...

Share This Page