The number 0-9 is given. You can arrange these numbers in any order, but they must all be used. The goal is to make the final number as small as possible (note that 0 cannot be the first place ). For example, given two 0 s, two 1 s, three 5 S, and one 8 s, the minimum number we get is 10015558.
Given a number, write a program to output the smallest number.
Input Format:
Each input contains one test case. Each test case contains 10 non-negative integers in one row, indicating that we have numbers 0, numbers 1 ,...... The number of digits 9. An integer is separated by a space. The total number of 10 numbers cannot exceed 50, and at least one number is not 0.
Output Format:
Output the smallest number in a row.
Input example:
2 2 0 0 0 3 0 1 0
Output example:
10015558
# Include<Stdio. h>Int main (){Int num [10] = {0}, sum =0;For (Int I =0; I <10; I ++) {scanf ("% D", & Num [I]); sum + = num [I];}For ( Int J = 1; j 10; j ++) { If (Num [J]! = 0) {printf ( " % d ", j); num [J]-= 1; Break ;}} for ( int K = 0; k 10; k ++) { while (Num [k]! = 0) {printf ( " % d ", k); num [k] --;} printf ( " \ n "); return 0 ;}