Swap the contents of two arrays:
#include <stdio.h>int main ()//exchange the contents of array A and the contents of Group B {int a[5] = { 1, 2, 3, 4, 5 };int b[5] = { 2, 3, 4, 5, 6 } ; int tmp;int i;printf ("before:\n");for (I = 0; i<sizeof (a) / sizeof (A[0]); i++) {printf ("%d ", a[i]);} printf ("\ n");for (i = 0; i<sizeof (b) / sizeof (b[0]); i++) {printf ("%d ", b[i]);} for (I = 0; i<sizeof (a) / sizeof (a[0]); i++) {tmp = a[i];a[i] = b[i];b[i] = tmp;} printf ("\ n"); printf ("after:\n"); for (I = 0; i<sizeof (a) / sizeof (a[0]); i++) {printf ("%d ", a[i]) }printf ("\ n"); for (i = 0; i<sizeof (b) / sizeof (b[0]);nbsp;i++) { printf ("%d ", b[i]);} return 0;}
This article is from the "10912110" blog, please be sure to keep this source http://10922110.blog.51cto.com/10912110/1718440
Swaps the contents of array A and the contents of Group B