快速排序
int partition(int*a, int left, int right){
int low;
if (left < right){
low = left;
int high = right;
int value = a[left];
while (low < high){
while (low < high&&a[high] >= value) high--;
a[low] = a[high];
while (low < high&&a[low] <= value) low++;
a[high] = a[low];
}
a[low] = value;
}
return low;
}
void quicksort(int* a, int left, int right){
if (left < right){
int mid = partition(a, left, right);
quicksort(a, left, mid - 1);
quicksort(a, mid + 1, right);
}
}
left<right不能加等于。