Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
136265 彭士宝 字符串反转 C++ Presentation Error 9 MS 264 KB 722 2025-11-09 23:26:18

Tests(0/1):


Code:

#include <iostream> #include <sstream> #include <algorithm> using namespace std; int main() { int T; cin >> T; // 读取测试样例的数量 cin.ignore(); // 忽略换行符 while (T--) { string line; getline(cin, line); // 读取一行文本 stringstream ss(line); string word; bool first = true; while (ss >> word) { reverse(word.begin(), word.end()); // 反转单词 if (!first) { cout << " "; // 在单词之间添加空格 } cout << word; first = false; } cout << endl; // 每个测试样例输出一行 } return 0; }