fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. freopen("out.txt","r",stdin);
  6. freopen("int.txt","w",stdout);
  7.  
  8. int n;
  9. cin>>n;
  10. int a[n];
  11. for(int i = 0; i <n ; i++){
  12. cin >> a[i];
  13. }
  14. for( int i = 0; i< n-1 ; i++){
  15. for( int j=0 ; j<n -1 -i ; j++){
  16. if(a[j]>a[j+1]){
  17. swap (a[j],a[j+1]);
  18. }
  19. }
  20. }
  21.  
  22. for(int i = 0; i <n ; i++){
  23. cout<< a[i]<< endl;
  24. }
  25.  
  26. }
  27.  
Success #stdin #stdout 0.56s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty