#includevoid input(int *,int ); void swap(int *,int ,int); void output(int *,int); int main() { int m,n; printf("How many numbers do you want ? "); scanf("%d",&n); int num[n]; printf("enter %d numbers: \n",n); input(num,n); printf("How many numbers do you want to move? (It must less than %d) ",n); scanf("%d",&m); while(m>=n) { printf("input error!\n"); scanf("%d",&m); } swap(num,0,n-1); swap(num,0,n-m-1); swap(num,n-m,n-1); printf("\nthe result of moving numvers is :\n"); output(num,n); return 0; } void input(int *a,int n) { int *head=a; while(a<=head+n-1) scanf("%d",a++); } void swap(int *a,int i,int j) { int temp; for(;i<=(i+j)/2;i++,j--)/*這個公式適用於所有需要中間元素參與的題*/ { temp=a[i]; a[i]=a[j]; a[j]=temp; } } void output(int *a,int n) { int *head=a; while(a<=head+n-1) printf("%d ",*(a++)); }