Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
151127 严鑫亮 字符串反转 C++ Accepted 7 MS 276 KB 554 2026-04-07 15:28:45

Tests(1/1):


Code:

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