Advertisement
Guest User

Untitled

a guest
May 24th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. Thiago Guimarães Almeida - 1411472
  2.  
  3. #include <stdio.h>
  4.  
  5. void soma_sub_um (int * vet, int tam)
  6. {
  7. int i;
  8. for (i=0; i<tam;i++)
  9. {
  10. if (i%2==0)
  11. *(vet+i)=*(vet+i)+1;
  12. else
  13. *(vet+i)=*(vet+i)-1;
  14. }
  15. }
  16. int main (void)
  17. {
  18. int n[1234],dim,i;
  19.  
  20. printf("Digite a dimensao do vetor de inteiros");
  21.  
  22. scanf("%d", &dim);
  23.  
  24. for (i=0;i<dim;i++)
  25. {
  26. printf("Digite o valor do %d numero do vetor",i+1);
  27. scanf("%d",&n[i]);
  28. }
  29.  
  30. soma_sub_um(n, dim);
  31.  
  32. for (i=0;i<dim;i++)
  33. printf("%d\n",n[i]);
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement