1503171912-ny-a water question
A water Question Time Limit: 1000 MS | memory limit: 65535 KB difficulty: 2
-
Description
-
Today, LZQ is playing a small game, but the number of this game is a little big. He is a little tired and wants to pull some people in to help him. Can you write a program to help him? This game is like this: there is a line of numbers. If we regard '5' in this line of numbers as spaces, then several non-negative integers (some integers may start with '0' and the '0' of these headers should be ignored, unless this integer is composed of several '0', then this integer is 0 ).
Your task is to sort and output the generated integers in ascending order. Please write a program to help LZQ!
-
Input
-
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 5000.
Input data guarantee: The calculated non-negative integer is not greater than 100000000. If all input data is 5, 0 is output.
-
Output
-
For each test case, the result of sorting the separated integers is output. Two Adjacent integers are separated by a space. Each group of output occupies one row.
-
Sample Input
-
0051231232050775
-
Sample output
-
0 77 12312320
-
Solutions
-
Pay attention to the following situations:
-
1. Start with 5
-
2. The end is not 5
-
3. 5 consecutive in the middle (I forgot to think about it. Please pay attention to it)
-
Code
-
#include
#include
#include using namespace std; char s[5100]; int num[5100]; int main() { int i,j,k; int len; int now; while(scanf("%s",s)!=EOF) { len=strlen(s); for(i=0;i