fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void swap_array(int n, int *a, int *b);
  4.  
  5. int main() {
  6. int i, *P, *Q;
  7. int a[10] = {100,99,98,97,96,95,94,93,92,91};
  8. int b[10] = {1,2,3,4,5,6,7,8,9,10};
  9.  
  10. P = a;
  11. Q = b;
  12.  
  13. swap_array(10, a, b);
  14.  
  15. for (i = 0; i < 10; i++) {
  16. printf("%d ", P[i]);
  17. printf("\n");
  18. printf("%d ", Q[i]);
  19. printf("\n");
  20. }
  21. system("pause");
  22. return 0;
  23. }
  24. void swap_array(int n, int *a, int *b){
  25. int t[10] = {0};
  26. int i;
  27. for(i=0; i<n; i++) {
  28. t[i] = a[i];
  29. a[i] = b[i];
  30. b[i] = t[i];
  31. }
  32. }
  33.  
  34.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
1 
100 
2 
99 
3 
98 
4 
97 
5 
96 
6 
95 
7 
94 
8 
93 
9 
92 
10 
91