Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int v[5],x,y,z,n;
  7. x=0;
  8.  
  9. printf ("Digite o tamanho do vetor \n");
  10. scanf ("%d" ,&n);
  11. printf ("Digite os componentes do vetor \n");
  12. while (x<n){
  13. scanf ("%d" ,&v[x]);
  14. x++;
  15. }
  16. x=0;
  17. z=0;
  18. while (z<n-1){
  19. while (x<n-1){
  20. z=x+1;
  21. if (v[x]>v[z]){
  22. y=0;
  23. y=v[x];
  24. v[x]=v[z];
  25. v[z]=y;
  26. x++;
  27. }
  28. }
  29. z++;
  30. x=0;
  31. }
  32. while (x<n){
  33. printf ("%d " ,v[x]);
  34. x++;
  35. }
  36.  
  37. }
Add Comment
Please, Sign In to add comment