//快速排序思想
#include<stdio.h>//找出数组分界线比关键字小的放在左边,比关键字大的放在右边
int QKpass(int a[],int low,int high)
{
int pos;
int key=a[low];
while(low<high)
{
while(key<a[high]&&low!=high)
{
high--;
}
if(key>a[high]&&low!=high)
{
a[low]=a[high];
low++;
}
while(key>=a[low]&&low!=high)
{
low++;
}
if(key<a[low]&&low!=high)
{
a[high]=a[low];
high--;
}
}
if(low == high)
{
a[low]=key;
pos=low;
return pos;
}
}
void QKsort(int a[],int low,int high)
{
int pos=0;
if(low<high)
{
pos=QKpass(a,low,high);
//左边
QKsort(a,low,pos-1);
//右边
QKsort(a,pos+1,high);
}
}
void main()
{
int a[8]={48,62,1,77,55,14,35,9};
int low=0;
int i;
int high=7;
QKsort(a,low,high);
for(i=0;i<8;i++)
{
printf("%d ",a[i]);
}
}