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