Run ID:151127
提交时间:2026-04-07 15:28:45
#include <iostream> #include <string> #include <algorithm> // reverse函数 using namespace std; int main() { int n; cin >> n; cin.ignore(); while (n--) { string s, word; getline(cin, s); for (char c : s) { if (c == ' ') { reverse(word.begin(), word.end()); cout << word << " "; word.clear(); } else word += c; } reverse(word.begin(), word.end()); cout << word << endl; } return 0; }