快速排序

void temp(int *l,int i,int j){
    int t=l[i];
    l[i]=l[j];
    l[j]=t;        
}
int partition(int *l,int low,int high){
    int privotkey=l[low];
    while(low<high){
        while(low<high&&l[high]>=privotkey)
            high--;
        temp(l,low,high);
        while(low<high&&l[low]<=privotkey)
            low++;
        temp(l,low,high);    
    }
return low;
}
void Qsort(int *L,int low,int high){
int privot;
if(low<high){

privot=partition(L,low,high);

Qsort(L,low,privot-1);
Qsort(L,privot+1,high);
}
}
void QuickSort(int *a,int length){
Qsort(a,1,length);

}
原文地址:https://www.cnblogs.com/qiaomu/p/4394953.html