c ++ (stringstream string divided spaces)

1205 words Flip

 

Time limit: 1 s
Space limitations: 128000 KB
Topic Level: Bronze Bronze
 
 
 
Title Description Description

Gives an English sentence, I hope you put the word order of a sentence are turned over

Enter a description Input Description

Inputs include an English sentence.

Output Description Output Description

Order word of the word reverse output

Sample input Sample Input

I love you

Sample Output Sample Output

you love I

Data range and prompt Data Size & Hint

Simple string manipulation

#include <iostream>
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <queue>
#include<sstream>
using namespace std;


int main()
{
    string a ;
    vector<string>res;
    getline(cin , a);
    stringstream ss(a);
    string b ;
    while(ss >> b)
    {
        res.push_back(b);
    }
    for(int i = res.size() - 1 ; i > 0 ; i --)
        cout << res[i] << " " ;
    cout << res[0] << endl ;



    return 0 ;
}

 

Guess you like

Origin www.cnblogs.com/nonames/p/11256444.html