Problem Description: enter a number in a row. If we regard '5' in this row as a space, several non-negative integers (some integers may start with '0, the '0' of these headers should be ignored unless the integer is composed of several '0' and the integer is 0 ).
Your task is to sort the generated integers in ascending order.
The Input contains multiple groups of test cases. Each group of Input data has only one row of numbers (no space between numbers), and the length of this line of numbers is not greater than 1000.
Input data guarantee: The calculated non-negative integer is not greater than 100000000, and the input data cannot all be composed of '5.
For each test case, Output results are sorted by integers. Two Adjacent integers are separated by a space. Each group occupies one row.
Sample Input
0051231232050775
Sample Output
0 77 12312320
The sorting is not a problem because the maximum number cannot exceed the integer.
Is how to split the string.
Details:
1 consecutive 5?
5 at the beginning of 2?
3 end with 5?
4. The end is not 5. Do not miss the ending number.
Simple questions. Relax.
# Include
# Include
# Include
# Include
# Include using namespace std; int main () {string strs; while (cin> strs) {int num = 0; vector
Vi; int I = 0; for (; I <(int) strs. size () & strs [I] = '5'; I ++); for (; I <(int) strs. size ();) {if ('5' = strs [I]) {vi. push_back (num); num = 0; for (I ++; I <(int) strs. size () & strs [I] = '5'; I ++) ;}else {num = num * 10 + (strs [I]-'0 '); I ++; // details if (I = (int) strs. size () vi. push_back (num); // details} sort (vi. begin (), vi. end (); for (int I = 0; I <(int) vi. size ()-1; I ++) {printf ("% d", vi [I]);} printf ("% d \ n", vi [vi. size ()-1]);} return 0 ;}