void quickSort(int *nums, int left, int right)
{
if (left > right) return;
int low = left;
int high = right;
int base = nums[left];
while (low < high)
{
while (nums[high] >= base && low < high)
{
high--;
}
nums[low] = nums[high];
while (nums[low] <= base && low < high)
{
low++;
}
nums[high] = nums[low];
}
nums[low] = base;
quickSort(nums, left, low-1);
quickSort(nums, high+1, right);
}
快速排序——使用广泛!!!
最新推荐文章于 2023-11-26 23:44:08 发布