Advertisement
STANAANDREY

sel_dir_sort

Mar 12th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {cout<<"nr de elemente=";
  6. int v[25],n,i,j,aux;
  7. cin>>n;
  8.  
  9. for(i=0;i<n;i++)
  10.  
  11. {
  12. cin>>v[i];}
  13. for(i=0;i<n-1;i++)
  14. for(j=i+1;j<n;j++)
  15. if(v[i]>v[j])
  16. { aux=v[i];
  17. v[i]=v[j];
  18. v[j]=aux; }
  19. cout<<endl;
  20. for(i=0;i<n;i++)
  21. cout<<v[i]<<" ";
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement