Description: Given an English sentence, you are asked to write a program that reverses the order of all the words in the sentence.
Input: The test input contains a test case that gives a string with a total length of not more than 80 in a row. The string consists of several words and a number of spaces, where the word is a string of letters (case-sensitive), the words are separated by 1 spaces, and the input guarantees that there are no extra spaces at the end of the sentence.
Output: The output of each test case takes one line, and the output is reversed after the sentence.
Inout:hello World Here I Come
Output:Come I here World Hello
is to be proficient in using the functions in string
1#include <iostream>2#include <string>3 using namespacestd;4 5 intMain ()6 {7 stringA, b,c;8 Getline (CIN, a);9 for(inti =0; I < a.size (); i++)Ten { One if(A[i] = =' ') A { -C.push_back (' '); -B.insert (0, c);//string insertion function theC.erase (0);//Delete a function - Continue; - } - C.push_back (A[i]); + } -C.push_back (' '); +B.insert (0, c); AB.erase (B.size ()-1); atcout << b <<Endl; -System"Pause"); - return 0; -}
Irony (c + + implementation)