快速排序出错在什么地方了,为什么得不到正确结果?
#include "stdafx.h"
#include <stdio.h>
int patition(int a[],int low, int high)
{
int pointkey;
pointkey=a[low];
while(low<high)
{
while((low<high)&&(a[high]>=pointkey)) --high;
a[low]=a[high];
while((low<high)&&(a[high]<=pointkey)) ++low;
a[high]=a[low];
}
a[low]=pointkey;
return low;
}
void qsort(int *a, int low, int high)
{
int k;
if(low<high)
{
k=patition(a,low,high);
qsort(a,low,k);
qsort(a,k+1,high);
}
}
void quicksort(int a[], int n)
{
qsort(a,0,n-1);
}
int main()
{
int a[10]={11,16,8,9,7,14,13,15,10,12};
int j;
quicksort(a,10);
for(j=0;j<10;j++)
printf("%d\t",a[j]);
return 1;
}