fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int t[1000007];
  4. int n,a;
  5. int main() {
  6. cin>>n;
  7. for(int i=1;i<=n;i++)
  8. {
  9. cin>>a;
  10. t[a]++;//zwiększamy o 1 element tablicy
  11. }
  12. for(int j=1;j<=1000000;j++)
  13. {
  14. for(int i=1;i<=t[j];i++)
  15. cout<<j<<" ";
  16. }
  17. // your code goes here
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5552KB
stdin
6
2 4 6 2 1 8
stdout
1 2 2 4 6 8