Hangzhou Electric 1106

Source: Internet
Author: User
Tags strtok

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

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.