快速排序的C语言实现:递归法
void quick_sort(int a[],int low,int high)
{
if(low >= high)
{
return;
}
int i = low;
int j = high;
int key = a[i];
while(i < j)
{
while((i < j) && (a[j] >= key))
{
j--;
}
if(i < j)
a[i++] = a[j];
while((i < j) && (a[i] <= key))
{
i++;
}
if(i < j)
a[j--] = a[i];
}
a[i] = key;//将key回归到中间位置
quick_sort(a,low, i-1);
quick_sort(a,i+1, high);
}