第1个回答 2012-01-08
void process(int a[], int n) // a是数组,n是数组长度
{
int mid = n / 2;
int i, count;
for (count = 0; count < 4; count++) // 移动四次
{
int tmp = a[mid - 1];
for (i = mid - 1; i > 0; i--)
{
a[i] = a[i - 1];
}
a[i] = tmp;
tmp = a[mid];
for (i = mid; i < n - 1; i++)
{
a[i] = a[i + 1];
}
a[i] = tmp;
}
}
int main(void)
{
int a[] = {1, 2, 3, 4, 5, 88, 99, 6, 7, 8, 9, 10};
process(a, 12);
int i = 0;
while (i < 12) printf("%d ", a[i++]);
return 0;
}