typedef int type;
typedef struct
{ int len;
type data[MAX];
}sqList;
void reverse10(sqList *a,int m,int n)//把数组中的元素从下标为n到 下标为n的元素逆置
{
for(int i=0;i<=(n-m)/2;i++)
{
int t;
t=a->data[m+i];
a->data[m+i]=a->data[n-i];
a->data[n-i]=t;
}
}
int leftmove10(sqList *a,int p)
{
//在第8题的基础上实际为数组交换位置,只不过此时不能用二分法时间复杂度为O(n) ,空间复杂度为O(1)
reverse10(a,0,a->len-1);
reverse10(a,0,a->len-p);
reverse10(a,a->len-p+1,a->len-1);
return 0;
}