快速排序算法
void qua_sor(int *arr,int h,int t)
{
if(h>=t) return;
int head=h;
int tail=t;
int key=arr[head];
while(head!=tail)
{
while(head!=tail)
{
if(key>arr[tail])
{
arr[head]=arr[tail];
break;
}
tail--;
}
while(head!=tail)
{
if(key<arr[head])
{
arr[tail]=arr[head];
break;
}
head++;
}
}
arr[head]=key;
qua_sor(arr,h,head-1);
qua_sor(arr,head+1,t);
}
{
if(h>=t) return;
int head=h;
int tail=t;
int key=arr[head];
while(head!=tail)
{
while(head!=tail)
{
if(key>arr[tail])
{
arr[head]=arr[tail];
break;
}
tail--;
}
while(head!=tail)
{
if(key<arr[head])
{
arr[tail]=arr[head];
break;
}
head++;
}
}
arr[head]=key;
qua_sor(arr,h,head-1);
qua_sor(arr,head+1,t);
}