#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int arr1[] = { 12, 52, 46, 52, 0 };
int arr2[] = { 52, 45, 23, 52, 61 };
int sz = sizeof(arr1) / sizeof(arr1[0]);
int tmp = 0;
int i = 0;
for (i = 0; i < sz; i++)
{
tmp = arr1[i];
arr1[i] = arr2[i];
arr2[i] = tmp;
}
printf("arr1[]=\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr1[i]);
}
printf("\narr2[]=\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr2[i]);
}
printf("\n");
return 0;
}
C语言,实现两个数组内容的交换(长度相同)
最新推荐文章于 2024-09-03 16:36:34 发布