#include <stdio.h>
void Quick(int Ele[],int low,int high);
int DividSort(int Ele[],int low,int high);
int main()
{
int i;
int date[]={49,38,65,97,76,13,27,49};
int len=sizeof(date)/sizeof(date[0]);
Quick(date,0,len-1);
for(i=0;i<len;i++)
{
printf("%d\n",date[i]);
}
return 0;
}
void Quick(int Ele[],int low,int high)
{
int pivot;
if(low<high)
{
pivot=DividSort(Ele,low,high);
printf("%d\n",pivot);
Quick(Ele,low,pivot-1);
Quick(Ele,pivot+1,high);
}
}
int DividSort(int Ele[],int low,int high)
{
int temp=Ele[low];
while(low<high)
{
while(low<high&&Ele[high]>=temp)
{
high--;
}
Ele[low]=Ele[high];
while(low<high&&Ele[low]<=temp)
{
low++;
}
Ele[high]=Ele[low];
}
Ele[low]=temp;
return low;
}
记得给出高位的下标len-1;