#include<stdio.h>
int sort(int a[],int left,int right);//
void swamp(int a[],int left,int right);
int partition(int a[],int left,int right);
int main()
{
int i,a[10]={2,30,13,22,45,67,43,1,67,90};
sort(a,0,9);//传入参数
for( i=0; i < 10; i++ )
{
printf("%d", a[i]);
}
printf("\n\n");
}
int sort(int a[],int left,int right)
{
int key;
key=partition(a,left,right);
sort(a,left,key);
sort(a,key+1,right);
}
int partition(int a[],int left,int right)
{
int p;
p=a[left];
while(left<right)
{
while(a[right]>p){
right--;
}
swamp(a,left,right);
while(a[left]<=p)
{
left++;
}
swamp(a,left,right);
}
return left;
}
void swamp(int a[],int left,int right)
{
int k;
k=a[left];
a[left]=a[right];
a[right]=k;
}