victorialais

Vetor crescente

Oct 2nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int vet[10];
  6. int i, j, v;
  7. printf("Digite uma sequencia de 10 números para compor um vetor \n\n");
  8. for (i = 0; i<10; i++)
  9.  
  10. {
  11. printf("Digite um numero para compor o vetor:");
  12. scanf("%d",&vet[i]);
  13. }
  14. for (i=0; i<10; i++)
  15. for(j=i+1; j<10; j++)
  16. {
  17. if (vet[i]>vet[j])
  18. {
  19. v=vet[i];
  20. vet[i]=vet[j];
  21. vet[j]=v;
  22. }
  23. }
  24.  
  25.  
  26. for(i=0;i<10;i++)
  27. printf(" %d",vet[i]);
  28. printf (" \n");
  29. system("pause");
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment