int partition(sqlist *a,int low,int high)
{
int pivotkey;
pivotkey=a[low].key;//用数组的第一个记录来表示枢轴
while(low<high)
{
while(low<high&&a[high].key>=pivotkey)
{
high--;
bijiao++;
}
if(low<high)
{
swap(a,low,high);
}
while(low<high&&a[low].key<=pivotkey)
{
low++;
bijiao++;
}
if(low<high)
{
swap(a,low,high);
}
}
return low;
}
void Qsort0(sqlist *a,int low,int high)//第一个元素做枢轴
{
int pivot;
if(low<high)
{
pivot=partition(a,low,high);//将a一分为二,算出中间值的下标
Qsort0(a,low,pivot-1);//对左边进行排序,递归
ans++;
Qsort0(a,pivot+1,high);//对右边进行排序,递归
ans++;
}
}