Run ID:158674
提交时间:2026-08-22 16:31:08
#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; }