#include<stdio.h>
#include<string.h>
void Swap(int a[],int i,int j){
for(;i<j;i++,j--){
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
void Move(int a[],int s,int p){
Swap(a,0,p-1);
Swap(a,p,s-1);
Swap(a,0,s-1);
}
void MyPrint(int a[],int size){
for(int i =0;i<size;i++){
printf("%d ",a[i]);
}
printf("\n");
}
int main(){
int a[10] = {0,1,2,3,4,5,6,7,8,9};
int size = sizeof(a)/sizeof(int);
printf(" 原序列: "); MyPrint(a,size);
Move(a,size,3);
printf("序列左移3:"); MyPrint(a,size);
int b[10] = {0,1,2,3,4,5,6,7,8,9}; //和a相同数列
Move(b,size,size-3); //右移其实可以看做是左移 右移3 = 左移size-3
printf("序列右移3:"); MyPrint(b,size);
return 0;
}