#include<stdio.h>
int Partiton(int *a,int low,int high){
int pivotkey=a[low];
while(low<high){
while(low<high && a[high]>=pivotkey)
--high;
a[low]=a[high];
while(low<high && a[low]<=pivotkey)
++low;
a[high]=a[low];
}
a[low]=pivotkey;
return low;
}
void QSort(int *a, int low ,int high){
if(low<high){
int pos=Partiton(a,low,high);
QSort(a,low,pos-1);
QSort(a,pos+1,high);
}
}
void main(){
int i;
int a[10] = {24, -2, 21, 10, 4, 5, 9, 13, 7, 101};
printf("未排序a前序列为:");
for(i=0;i<10;i++) printf("%d ",a[i]);
printf("\n____________________________\n");
QSort(a,0,9);
printf("快速排序结果为:");
for(i=0;i<10;i++) printf("%d ",a[i]);
printf("\n____________________________\n");
}