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