#include "stdio.h" int main() { int arr1[5]={1,2,3,4,5}; int arr2[5]={2,3,4,5,6}; int arr3[5]; int i; for(i=0;i<sizeof(arr1)/sizeof(arr1[0]);i++) { arr3[i]=arr1[i]; arr1[i]=arr2[i]; arr2[i]=arr3[i]; } for(i=0;i<sizeof(arr1)/sizeof(arr1[0]);i++) { printf("%d ",arr1[i]); } printf("\n"); for(i=0;i<sizeof(arr2)/sizeof(arr2[0]);i++) { printf("%d ",arr2[i]); } return 0; }
输出arr1[5]={2,3,4,5,6}
输出arr2[5]={1,2,3,4,5}