1503171912-ny-a water problem

Source: Internet
Author: User

Time limit for a water problem: +Ms | Memory Limit:65535KB Difficulty:2
Descriptive narrative
Today Lzq is playing a small game, but the number of games is a little bit big, he is tired of playing alone. Want to pull some more people in to help him. Can you write a program to help him? This game is this: there is a row of numbers, assuming that we take this line of numbers in the ' 5 ' as a space, then we get a line with a space cut a number of non-negative integers (maybe some integers start with ' 0 ', these heads ' 0 ' should be ignored, unless the integer is a number of ' 0 ', then this integer is 0).


Your task is: to these cut get the whole number, according to from small to large order output, everyone hurriedly write a program to help Lzq bar.

Input
Input includes multiple sets of test cases, each set of input data only a row of numbers (no space between the numbers). The length of this line number is not greater than 5000.



Input data Assurance: The resulting non-negative integers are not greater than 100000000, assuming that the input data is all 5. The output is 0.

Output
for each test example. The output is cut to get the result of sorting the integers. The adjacent two integers are separated by a space. One row for each set of outputs.

Example input
0051231232050775
Example output
0 77 12312320
Thinking of solving problems
   Here are a few things to note:
        1, the beginning is 5
        2, End not 5
        3, the middle of a continuous 5     (This forget I considered, we have to pay attention to AH)
 code 
 
 #include < stdio.h> #include <string.h> #include <algorithm>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<len;i++) if (s[i]!= ' 5 ') break;k =0;now=0;for (; i<len;i++) {if (s[i]== ' 5 ') {num[k++]=now;now=0;for (; i<len;i++) if (s[i]!= ' 5 ') break;i--;//remember to consider continuous 5 of the situation}else now=now*10+s[i]-' 0 ';} if (s[len-1]!= ' 5 ') Num[k++]=now;sort (Num,num+k), for (i=0;i<k;i++) {printf ("%d", num[i]), if (i!=k-1) printf ("");} printf ("\ n");} return 0;} 


1503171912-ny-a water problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.