Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
158674 章泽原 分割排序 C++ Accepted 1 MS 284 KB 1015 2026-08-22 16:31:08

Tests(1/1):


Code:

#include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> using namespace std; int main() { string s; while (cin >> s) { vector<long long> nums; string temp; for (char ch : s) { if (ch == '5') { if (!temp.empty()) { long long x = stoll(temp); nums.push_back(x); temp.clear(); } } else { temp += ch; } } // 处理最后一段 if (!temp.empty()) { long long x = stoll(temp); nums.push_back(x); } sort(nums.begin(), nums.end()); // 输出 for (int i = 0; i < nums.size(); i++) { if (i > 0) cout << " "; cout << nums[i]; } cout << endl; } return 0; }