Test instructions
Enter a line of numbers, if we take this line of the number of ' 5 ' as a space, then we get a line with a space separated by a number of non-negative integers (maybe some integers start with ' 0 ', these heads ' 0 ' should be ignored, unless the integer is composed of several ' 0 ', then this integer is 0).
Your task is to sort the output from small to large for these segmented integers
The input contains multiple sets of test cases, each set of input data with only one row of numbers (no spaces between the numbers), and the length of this line is not greater than 1000.
Input data Assurance: The resulting non-negative integers are not greater than 100000000, and the input data cannot be composed of ' 5 '.
Sample Input
0051231232050775
Sample Output
0 77 12312320
This notebooks should be enumerated. But now I don't.
Here are three functions to solve.
Function One:
Sort () function, this function, used previously, C language also has but C + + is simpler, note to include header files and C + + input and output header files.
Function Two:
Char *strtok (char s[], const char *d); This is the prototype, which decomposes the string into a set of strings. The string that s wants to break down. D is a delimiter character because all D is substituted for the first execution of this function, so you need to change s to NULL when you call it again (the C language takes it as the last character of the string to represent the end of the string. ") ").
Function Three:
Atoi () (representing alphanumeric to integer) is a function that converts a string into an integer number. belong to common functions.
#include <iostream>using namespace STD;#include <algorithm>#include <stdio.h>#define M 10005intA[M];CharB[M];intMain () { while(gets (b)) {Char*p; a[0] = Atoi (Strtok (b,"5"));intx =1; while(P = strtok (NULL,"5")) a[x++] = Atoi (p); Sort (a,a+x);inti =0;printf("%d", a[0]); for(i =1; i < x; i++)printf("%d", A[i]);printf("\ n"); }return 0;}
Hangzhou Electric 1106