Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
160622 赵乐骏 字符串反转 C++ Presentation Error 8 MS 276 KB 694 2026-09-24 22:05:38

Tests(0/1):


Code:

#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; }