C语言指针快速排序
自己写了 有错误 能不能 帮我修改下#include <stdio.h>
void quicksort (int *a, int *low, int *high);
int split (int *a, int *low, int *high);
#define N 10
int main(void)
{
int *p;
int a[N];
for (p = a; p < a + N; p++)
{
scanf ("%d", p);
}
p = a;
quicksort (p, &a[0], &a[N - 1]);
for (p = a; p < a + N; p++)
{
printf ("%-3d", *p);
}
return 0;
}
void quicksort (int *a, int *low, int *high)
{
int *middle;
if (low >= high) return;
middle = split (a, low, high);
quicksort (a, low, middle - 1);
quicksort (a, middle + 1, high);
}
int split (int *a, int *low, int *high)
{
int part = *low;
for (;;)
{
while (low < high && part <= *high)
high--;
if (low >= high) break;
*low++ = *high;
while (low < high && *low <= part)
low++;
if (low >= high) break;
*high-- = *low;
}
*high = part;
return high;
}