Guest User

Untitled

a guest
Jun 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. main(){
  5. // n posição do vetor, contador do laço
  6. int aux, n, m, bolha[10];
  7.  
  8. for(n =1; n<= 10; n++){
  9. printf("Digite o %d numero do vetor:", n);
  10. scanf("%d", &bolha[n]);
  11. }
  12.  
  13. printf("\nVetor original:\n)");
  14. for(n =1; n<= 10; n++){
  15. printf("%d\t", bolha[n]);
  16. }
  17.  
  18. for(n =1; n<= 10; n++){
  19. // n+1 pra começar do index pra frente
  20. for(m = n + 1; m <= 10; m++){
  21. if(bolha[n] > bolha[m]){
  22. aux = bolha[m];
  23. bolha[m] = bolha[n];
  24. bolha[n] = aux;
  25. }
  26. }
  27. }
  28.  
  29. printf("\nVetor ordenado:\n");
  30. for(n =1; n<= 10; n++){
  31. printf("%d\t", bolha[n]);
  32. }
  33. printf("\n\n");
  34. system("pause");
  35. return(0);
  36. }
Add Comment
Please, Sign In to add comment