题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805298269634560
题解:
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 11 int *b = new int[s]; 12 int f = 0; 13 for (int i = 1; i < 10; i++){ 14 if (a[i] != 0){ 15 b[f++] = i; 16 a[i]--; 17 break; 18 } 19 } 20 for (int i = 0; i < 10; i++){ 21 while (1){ 22 if (a[i] != 0){ 23 b[f++] = i; 24 a[i]--; 25 } 26 else break; 27 } 28 29 } 30 for (int i = 0; i < f; i++) 31 cout << b[i]; 32 return 0; 33 }