quicksort

时间:2021-08-02 04:14:13

快排。。。。

void quicksort(int *a,int left,int right){
if(left >= right){
return ;
}
int i = left;
int j = right;
int key = a[left]; while(i < j)
{
while(i < j && key <= a[j]){
j--;
}
a[i] = a[j];
while(i < j && key >= a[i]){
i++;
} a[j] = a[i];
} a[i] = key;
quicksort(a, left, i - );
quicksort(a, i + , right);
}