Expand|Select|Wrap|Line Numbers
- 13 void f1(int a[]) {
- 14 const int m = 100;
- 15 int b[m];
- 16 for (int j = 0; j < m; ++j) b[j] = 0;
- 17 for (int i = 0; i < 10; ++i) ++b[a[i]];
- 18 for (int i = 0, j = 0; j < m; ++j)
- 19 for (int k = b[j]; k > 0; --k) a[i++] = j;
- 20 return;
- 21 }
- 22 int main (int argc, char **argv)
- 23 {
- 24 int a[10];
- 25 char reply;
- 26 for (int i = 0; i < 10; i++) a[i] = 100 - i;
- 27 f1(a);
- 28 for (int i = 0; i < 10; i++) cout << i << ". " << a[i] << endl;
- 29 cout << "Press q (or any other key) followed by 'Enter' to quit: ";
- 30 cin >> reply;
- 31 return 0;
- 32 }
- OUTPUT:
- 0. 91
- 1. 92
- 2. 93
- 3. 94
- 4. 95
- 5. 96
- 6. 97
- 7. 98
- 8. 99
- 9. 91
- Press q (or any other key) followed by 'Enter' to quit: