1023 组个最小数

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main(){
 5     int a[10], s = 0;
 6     for (int i = 0; i < 10; i++){
 7         cin >> a[i];
 8         s += a[i];
 9     }
10     int *b = new int[s];
11     int f = 0;
12     for (int i = 1; i < 10; i++){
13         if (a[i] != 0){
14             b[f++] = i;
15             a[i]--;
16             break;
17         }
18     }
19     for (int i = 0; i < 10; i++){
20         while (1){
21             if (a[i] != 0){
22                 b[f++] = i;
23                 a[i]--;
24             }
25             else break;
26         }
27         
28     }
29     for (int i = 0; i < f; i++){
30         cout << b[i];
31     }
32     cout << endl;
33     return 0;
34 }

猜你喜欢

转载自www.cnblogs.com/zb520/p/9357328.html