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