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

data2[0]=1
data2[1]=2
data2[2]=3
data2[3]=4
data2[4]=5