fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. freopen("in.txt","w",stdout);
  8.  
  9. freopen("out.txt","r",stdin);
  10.  
  11. int n;
  12. cin>>n;
  13.  
  14. int arr[n+1];
  15.  
  16. for (int i=1; i<=n; i++){cin>>arr[i];}
  17.  
  18. //Selection sort
  19.  
  20. for (int i=1;i<n;i++){
  21. for(int j=i+1;j<=n;j++){
  22. if(arr[i]<arr[j]){
  23. swap(arr[i],arr[j]);
  24. }
  25. }
  26. }
  27. // Selection sort ended
  28.  
  29. for (int i=1;i<=n;i++){cout<<arr[i]<<"\n";}
  30.  
  31. return 0;
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty