Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define K 10
- using namespace std;
- int b[K], i, j;
- void count_sort( int a[], int n) {
- for( i=0; i<=K; i++ ) b[i]=0;
- for( i=0; i<n; i++ ) b[a[i]]++;
- for( i=0; i<=K; i++ )
- for( j=0; j<b[i]; j++ ) cout << i;
- }
- int main(){
- int *a, n;
- cin >> n;
- a = new int [n];
- for( i=0; i<n; i++ ) cin >> a[i];
- count_sort( a, n );
- delete [] a;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment