Public paste
By: Guest | Date: Nov 9 2007 21:18 | Format: None | Expires: never | Size: 1.16 KB | Hits: 1167

  1. Write the algorithm and its corresponding C++ implementation for a value-returning function that receives a string corresponding to a sentence and returns a string with the words reversed and separated by the last punctuation mark found in the original string.
  2. Write a program to test your function with those strings provided in the file input5.txt that accompanies this handout.
  3. To implement your function you must use classes stack and queue from the Standard Template Library (STL).
  4. Your program ( main() ) must read from the file a string, pass it to your value-returning function, and then print the returned string.
  5. The input file may contain several strings finished by a new line character (Enter) each. Words are separated by one or more blanks or punctuation marks (see the functions provided by header file cctype on page 857).
  6. For the algorithm of your function, use pseudocode similar in type to the example shown on page 258 of the textbook for function getStudentData. For the algorithm of your main program use the example on page 257 as your reference.
  8. Example:
  10. For an input like
  12. Therefore, just do it
  14. The output should be
  16. eroferehT,,tsuj,od,ti,