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