Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
50723 | 冯诚阳 | 字符串反转 | C++ | Accepted | 6 MS | 272 KB | 489 | 2023-07-12 16:22:42 |
#include <iostream> #include <string.h> using namespace std; int main() { char s[1005]; int n; cin >> n; getchar(); while (n--) { cin.getline(s, 1005); int k = 0; int m = strlen(s); for (int i = 0; i < m; i++) { if (s[i] == ' ') { for (int j = i - 1; j >= k; j--) { cout << s[j]; } cout << " "; k = i + 1; } } for (int i = m - 1; i >= k; i--) { cout << s[i]; } cout << endl; } }