Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- main(){
- // n posição do vetor, contador do laço
- int aux, n, m, bolha[10];
- for(n =1; n<= 10; n++){
- printf("Digite o %d numero do vetor:", n);
- scanf("%d", &bolha[n]);
- }
- printf("\nVetor original:\n)");
- for(n =1; n<= 10; n++){
- printf("%d\t", bolha[n]);
- }
- for(n =1; n<= 10; n++){
- // n+1 pra começar do index pra frente
- for(m = n + 1; m <= 10; m++){
- if(bolha[n] > bolha[m]){
- aux = bolha[m];
- bolha[m] = bolha[n];
- bolha[n] = aux;
- }
- }
- }
- printf("\nVetor ordenado:\n");
- for(n =1; n<= 10; n++){
- printf("%d\t", bolha[n]);
- }
- printf("\n\n");
- system("pause");
- return(0);
- }
Add Comment
Please, Sign In to add comment