fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void mcout(int* l,int n)
  5. {
  6. for(int i=0;i<n;i++)
  7. {
  8. cout<<l[i]<<" ";
  9. }
  10. }
  11.  
  12. int main() {
  13. int n[100];
  14. int a,b,c;
  15. cin>>a;
  16. b=1;
  17. for(int i=0;i<a;i++)
  18. {
  19. cin>>n[i];
  20. }
  21. for(int i=0;i<a;i++)
  22. {
  23. for(int j=0;j<a-b;j++)
  24. {
  25. if(n[j]>n[j+1])
  26. {
  27. c=n[j];
  28. n[j]=n[j+1];
  29. n[j+1]=n[j];
  30. }
  31. }
  32. b++;
  33. }
  34. mcout(n,a);
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 4388KB
stdin
8 3 4 5 6 7 1 3 2
stdout
1 1 1 1 1 1 2 2