logic

This is a discussion on logic within the C++ Programming forums, part of the General Programming Boards category; Is it possible to write a script in C++ that will take a input sentence " Now is the time ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    1

    logic

    Is it possible to write a script in C++ that will take a input sentence " Now is the time for all good men to come to the aid of their country" . And sorted the sentence in alpha order (aid all come country for good is men now of the the their to to) As well check that the sentence is longer than 80 characters.

    Thread 1 accepts the input
    Thread 2 does the sorting and manipulation
    Thread 3 deliver the output to the screen


    C++ Newbie,

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Yes it is possible! Any more questions?

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Read individual words from sentence into vector<string> or list<string> container. Call the appropriate sort function/member function for the given container. Iterate through the container and sum up the lengths of the individual strings to determine character count. Sounds very easy.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    Create an array of strings for the number of words present in the sentence. Use any standard sorting method of sorting the array of strings, and then concatenate them using strcat().

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    This is hardly worthy of multithreading, assuming that is what you ment by "Thread 1 does this..etc"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 12:05 PM
  2. Logic
    By LordBronz in forum C++ Programming
    Replies: 6
    Last Post: 05-23-2006, 05:41 PM
  3. Actors, cues, event based logic.
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 04-27-2006, 10:58 PM
  4. Circular Logic
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-15-2001, 08:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21