Run ID:160621
提交时间:2026-09-24 21:48:51
#include<bits/stdc++.h> using namespace std; int main(){ int T; cin >> T; cin.ignore(); while (T--) { string line; getline(cin, line); string word = ""; string result = ""; for (int i = 0; i <= line.size(); i++) { if (i == line.size() || line[i] == ' ') { reverse(word.begin(), word.end()); if (!result.empty()) result += " "; result += word; word = ""; } else { word += line[i]; } } cout << result << endl; } return 0; }