Run ID:136265
提交时间:2025-11-09 23:26:18
#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; }