fork(1) download
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. const int N=200000;
  5. int a[N];
  6. int main(){
  7. int n;
  8. cin>>n;
  9. for(int i=0;i<n;i++)
  10. cin>>a[i];
  11. for(int i=n-1;i>=1;i--)
  12. for(int j=0;j<=i-1;j++)
  13. if(a[j]>a[j+1])
  14. swap(a[j],a[j+1]);
  15. for(int i=0;i<n;i++) cout<<a[i]<<" ";
  16. return 0;
  17. }
Success #stdin #stdout 0s 5540KB
stdin
5
1 5 3 4 2
stdout
1 2 3 4 5