Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "iostream"
- using namespace std;
- int c[10] = {0,0,0,0,0,0,0,0,0,0}, a[10] = {1,2,6,3,8,3,4,6,9,7}, b[11];
- void main()
- {
- for (int i = 0; i < 10; i++)
- {
- c[a[i]]++;
- }
- for (int i = 1; i < 10; i++)
- {
- c[i] = c[i] + c[i-1];
- }
- for (int i = 9; i >= 0; i--)
- {
- b[c[a[i]]] = a[i];
- c[a[i]]--;
- }
- for (int i = 1; i < 11; i++)
- {
- cout << b[i] << " ";
- }
- cout << endl;
- system("pause");
- }
Add Comment
Please, Sign In to add comment