题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
#include <iostream> #include <sstream> #include <vector> #include <algorithm> using namespace std; int main() { string sentence, temp; stringstream ss; vector<string> words; getline(cin, sentence); ss << sentence; while(ss >> temp) { words.push_back(temp); } vector<string> res(words.rbegin(), words.rend()); for (auto &it : res) cout << it<<" "; } // 64 位输出请用 printf("%lld")