关于快排的一个bug
#include <stdio.h>int a[8] = {3,5,0,8,2,4,9,3};
int partition(int start, int end)
{
int len = end - start, j, mid;
int pivot = a[start];
int temp[len];
for (j = start + 1; j <= end; j++)
temp[j] = a[j];
for (j = start + 1; j <= end; j++)
{
if (temp[j] < pivot)
a[start++] = temp[j];
else
a[end--] = temp[j];
}
a[start] = pivot;
return mid = start;
}
void quicksort(int start, int end)
{
int mid;
if (end > start)
{
mid = partition(start, end);
quicksort(start,mid - 1);
quicksort(mid + 1, end);
}
}
int main(void)
{
int i;
quicksort(0,7);
for (i =0; i <= 7; i++)
printf("%d\n", a[i]);
return 0;
}
程序出错 实在找不出来bug 哪位帮我查一下错在哪里?谢