Advertisement
whoisbsa

ex 3

Nov 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. trocaVetor(int n[]);
  2. int main()
  3. {
  4.     int n[20], i;
  5.     setlocale(LC_ALL,"Portuguese");
  6.  
  7.     for (i=0; i<5; i++){
  8.         printf("%dº: ", i+1);
  9.         scanf("%d", &n[i]);
  10.     }
  11.  
  12.     trocaVetor(n);
  13.  
  14.     return 0;
  15. }
  16.  
  17. int trocaVetor(int n[])
  18. {
  19.     int i, j, c=5, aux=0;
  20.  
  21.     for (i=0; i<5; i++) {
  22.         for(j=0; j<5; j++){
  23.             aux = n[i];
  24.             n[i] = n[j];
  25.             n[j] = aux;
  26.         }
  27.         printf("\n%dº: %d", i+1, n[i]);
  28.     }
  29.  
  30.     return;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement