| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 153310 | Kevin | 分割排序 | C++ | Accepted | 2 MS | 280 KB | 1214 | 2026-05-14 15:40:25 |
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string s; // 多组输入,用cin读字符串,遇到EOF自动结束 while (cin >> s) { int num[1000]; int cnt = 0; string temp = ""; // 用来存当前分割出来的数字字符串 for (int i = 0; i < s.size(); ++i) { if (s[i] != '5') { temp += s[i]; } else { // 遇到'5',把temp转成数字存起来(temp不为空才处理) if (!temp.empty()) { int x = stoi(temp); // 自动处理前导零,"00" → 0 num[cnt++] = x; temp = ""; } } } // 处理最后一段(如果不是空的) if (!temp.empty()) { int x = stoi(temp); num[cnt++] = x; } // 从小到大排序 sort(num, num + cnt); // 输出(无末尾多余空格) for (int i = 0; i < cnt; ++i) { if (i > 0) cout << " "; cout << num[i]; } cout << endl; } return 0; }