Advertisement
Finnit

Counting Sort

Sep 5th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define N 100
  6.  
  7. int f[N] = {0};
  8.  
  9. int main(void) {
  10.     int n, x;
  11.     scanf("%d",&n);
  12.     for(int i = 0; i < n; ++i) {
  13.         scanf("%d",&x);
  14.         ++f[x];
  15.     }
  16.     for(i = 0; i < N; ++i)
  17.         for(j = 0; j < f[i]; ++j)
  18.             printf("%d ",i);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement