void reserve(int* a, int left, int right)
{
int temp = 0;//用于存贮中间变量
for (int i = left; i <= (left+right)/2; i++)
{
temp = a[i];
a[i] = a[right - i+left];
a[right - i+left] = temp;
}
}
int main()
{
int m = 0;//向后移动几位
printf("请输入m的值\n");
scanf("%d", &m);
int a[10];
printf("请输入数组的元素\n");
for (int i = 0; i < 10; i++)
{
scanf("%d", &a[i]);
}
reserve(a, 0, m-1);
for (int i = 0; i < 10; i++)
{
printf("%d ", a[i]);
}
printf("\n");
reserve(a, m, 9);
for (int i = 0; i < 10; i++)
{
printf("%d ", a[i]);
}
printf("\n");
reserve(a, 0, 9);
printf("打印翻转后的数组\n");
for (int i = 0; i < 10; i++)
{
printf("%d ", a[i]);
}
return 0;
}