Run ID:110962
提交时间:2025-02-24 19:55:58
#include <iostream> #include <vector> #include <algorithm> // 用于 sort #include <sstream> // 用于 stringstream using namespace std; int main() { string input; while (getline(cin, input) && input != "#") { vector<int> numbers; // 存储分割得到的整数 stringstream ss(input); string token; while (getline(ss, token, '5')) { if (!token.empty()) { numbers.push_back(stoi(token)); // 将子字符串转换为整数 } } // 对整数进行排序 sort(numbers.begin(), numbers.end()); // 输出排序后的整数序列 for (int i = 0; i < numbers.size(); ++i) { if (i > 0) { cout << " "; } cout << numbers[i]; } cout << endl; } return 0; }