#include <stdio.h>
int main()
{
int i,a[100],number,mid,temp1,temp2;
printf("How many numbers do you want to enter?
");
scanf("%d",&number);//确定数组长度
printf("Please input array:
");
for(i=0;i<number;i++)
scanf("%d",&a[i]);
printf("your array is:
");
for(i=0;i<number;i++)
printf("%5d",a[i]);
printf("
");
if(number%2==1)//输入奇数位序列
{
mid=(number-1)/2;
for(i=0;i<=mid;i++)
{
temp1=a[mid-i];
a[mid-i]=a[mid+i];
a[mid+i]=temp1;
}
}
else//输入偶数位序列
{
for(i=0;i<=number/2-1;i++)
{
temp2=a[i];
a[i]=a[number-(i+1)];
a[number-(i+1)]=temp2;
}
}
printf("逆序排序后的数组为:
");
for(i=0;i<number;i++)
printf("%5d",a[i]);
return 0;
}