Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i,j,n,loc,temp,min,V[100];
  8. cout<<"introdu numarul de elemente:";
  9. cin>>n;
  10.  
  11. for(i=0;i<n;i++)
  12. {
  13. cin>>V[i];
  14. }
  15.  
  16. for(i=0;i<n-1;i++)
  17. {
  18. min=V[i];
  19. loc=i;
  20. for(j=i+1;j<n;j++)
  21. {
  22. if(min<V[j])
  23. {
  24. min=V[j];
  25. loc=j;
  26. }
  27. }
  28.  
  29. temp=V[i];
  30. V[i]=V[loc];
  31. V[loc]=temp;
  32. }
  33.  
  34. cout<<"Numere sortate: ";
  35. for(i=0;i<n;i++)
  36. {
  37. cout<<V[i]<<" ";
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement