69,373
社区成员
发帖
与我相关
我的任务
分享
int main(int argc, char const *argv[])
{
int a[4] ={23,45};
quicksort(a,0,1);
return 0;
}
int partion(int a[],int low,int high)
{
int privt = a[low];
while(low<high)
{
while(low<high&&a[high] >= privt) --high;
a[low++] = a[high];
while(low<high&&a[low] <= privt) ++low;
a[high--] = a[low];
}
a[low] = privt;
return low;
}
void quicksort(int a[],int low,int high){
while(low<high){
int pos = partion(a,low,high);
quicksort(a,low,pos-1);
quicksort(a,pos+1,high);
}
}