题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
//https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3?tpId=37&tqId=21236&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title= #include <iostream> #include <sstream> #include <vector> #include <algorithm> using namespace std; int main() { string s; while (getline(cin, s)) { vector<string> ans; stringstream ss(s); while(ss>>s) ans.push_back(s); reverse(ans.begin(), ans.end()); for(int i = 0;i<ans.size();i++){ if(i) cout << ' '; cout << ans[i]; } cout << endl; } }