int split(int a[], int low, int high)
{
int part_element = a[low];
for (;;)
{
while (low < high && part_element <= a[high])
high--;
if (low >= high) break;
a[low++] = a[high];
while (low < high && a[low] <= part_element)
low++;
if (low >= high) break;
a[high--] = a[low];
}
a[high] = part_element;
return high;
}
void sort(int a[], int low, int high)
{
int middle;
if (low >= high) return;
middle = split(a, low, high);
sort(a, low, middle - 1);
sort(a, middle + 1, high);
}
快速排序算法
最新推荐文章于 2024-08-31 11:16:19 发布