int quickOnce(int * data, int left, int right)
{
int tmp;
tmp = data[left];
while(left<right)
{
//右边找个小于tmp的数放到左边
while(left<right)
{
if(data[right] < tmp)
{
data[left] = data[right];
break;
}
right--;
}
//左边找个大于tmp的数放到右边
while(left<right)
{
if(data[left] > tmp)
{
data[right] = data[left];
break;
}
left++;
}
}
data[left] = tmp; //left = right
return left; //返回枢轴点位置
}
void quickSort(int * data, int left, int right)
{
int pos;
if(left < right)
{
//分成三部分
pos = quickOnce(data, left, right);
//排左边
quickSort(data, left, pos-1);
//排右边
quickSort(data, pos+1, right);
}
}