1. 程式人生 > >1023 組個最小數

1023 組個最小數

code esp using while cout != clas for i++

 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 }

1023 組個最小數