交换两个数组的内容:
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int main() { int arr1[10] = {1,2,3,4,5,6,7,8,9,0}; int arr2[10] = {0,9,8,7,6,5,4,3,2,1}; int i = 0; for (i = 0; i < sizeof(arr1) / sizeof(arr1[0]); i++) { int tmp = arr1[i]; arr1[i] = arr2[i]; arr2[i] = tmp; } printf("arr1:"); for (i = 0; i < sizeof(arr1) / sizeof(arr1[0]); i++) { printf("%d", arr1[i]); } printf("\narr2:"); for (i = 0; i < sizeof(arr1) / sizeof(arr1[0]); i++) { printf("%d", arr2[i]); } printf("\n"); system("pause"); return 0; }