哪位大哥 帮我解释一下这个快速排序啊! 详细点
#include <stdio.h>void swap(int* a,int p,int q)
{
int t;
t = a[p];
a[p] = a[q];
a[q] = t;
}
void myqsort(int* a,int left,int right)
{
int mid,i,last;
if(left >= right){
return;
}
mid = (left + right) / 2;
swap(a,left,mid);
last = left;
for(i = left+1;i<=right;i++)
{
if(a[left] > a[i]){
swap(a,++last,i);
}
}
swap(a,left,last);
myqsort(a,left,last-1);
myqsort(a,last+1,right);
}
main()
{
int a[]={1,3,2,5,8,6,9},i;
myqsort(a,0,6);
for(i=0;i<7;i++){
printf("%d ",a[i]);
}
printf("\n");
}