#include <stdio.h>
int main()
{
int arr1[] = { 0,1,2,3,4 };
int arr2[] = { 5,6,7,8,9 };
int i = 0, j = 0;
int sz = sizeof(arr1) / sizeof(arr1[0]);
int left = 0, right = sz - 1;
printf("交换前\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr1[i]);
}
printf("\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr2[i]);
}
printf("\n");
while (left <= right)
{
int tmp1 = arr1[left];
arr1[left] = arr2[left];
arr2[left] = tmp1;
int tmp2 = arr1[right];
arr1[right] = arr2[right];
arr2[right] = tmp2;
if (left == right)
{
tmp1 = arr1[left];
arr1[left] = arr2[right];
arr2[right] = tmp1;
}
left++;
right--;
}
printf("交换后\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr1[i]);
}
printf("\n");
for (i = 0; i < sz; i++)
{
printf("%d ", arr2[i]);
}
printf("\n");
return 0;
}