C++实现快速排序
发表于:2024-11-27 作者:热门IT资讯网编辑
编辑最后更新 2024年11月27日,void quickSort(int a[], int low, int high){if (low <= high)return;int i = low;int j = high;int key =
void quickSort(int a[], int low, int high)
{
if (low <= high)
return;
int i = low;
int j = high;
int key = a[i];
while (i < j)
{
while (i < j && a[j] >= key)
--j;
a[i] = a[j];
while (i < j && a[i] <= key)
++i;
a[j] = a[i];
}
a[i] = key;
quickSort(a, low, i - 1);
quickSort(a, i + 1, high);
}