Guest User

Untitled

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