Run ID:160622

提交时间:2026-09-24 22:05:38

#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 != "") { result += " "; } result += word; word = ""; } else { word += line[i]; } } cout << result << endl; } return 0; }