fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int *x, int *y);
  4.  
  5. int main(void) {
  6. int x[5] = {1,2,3,4,5};
  7. int y[5] = {6,7,8,9,10};
  8.  
  9. int i;
  10. for(i=0;i<5;i++){
  11. swap(&x[i], &y[i]);
  12. printf("%d\n", x[i]);
  13. printf("%d\n", y[i]);
  14. }
  15.  
  16. return 0;
  17. }
  18.  
  19. void swap(int *x, int *y) {
  20. int w;
  21. w = *x;
  22. *x = *y;
  23. *y = w;
  24. }
  25.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
6
1
7
2
8
3
9
4
10
5