fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define TAM 7
  4. void ordenacaoVetor(int vet[])
  5. {
  6. int i,j, valor;
  7. for(i=1;i<TAM;i++)
  8. {
  9. valor = vet[i];
  10. printf("\n\nInserindo vet[%d]=\'%d\'\n",i,valor);
  11. for(j=i-1;vet[j]>valor && j>=0;j--)
  12. {
  13. vet[j+1]=vet[j];
  14. printf("%d",vet[j]);
  15. }
  16. vet[j+1]=valor;
  17. printf("%d",vet[j+1]);
  18. }
  19. }
  20. int main()
  21. {
  22. int vet[TAM]={6,3,4,1,7,2,5};
  23. ordenacaoVetor(vet);
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout

Inserindo vet[1]='3'
63

Inserindo vet[2]='4'
64

Inserindo vet[3]='1'
6431

Inserindo vet[4]='7'
7

Inserindo vet[5]='2'
76432

Inserindo vet[6]='5'
765