
Code
#include"stdio.h"
void quickSort(int a[],int left,int right)
{
int i,j,temp;
i=left;
j=right;
temp=a[left];
if(left>right)
return;
while(i!=j)/*找到最终位置*/
{
while(a[j]>=temp && j>i)
j--;
if(j>i)
a[i++]=a[j];
while(a[i]<=temp && j>i)
i++;
if(j>i)
a[j--]=a[i];
}
a[i]=temp;
quickSort(a,left,i-1);/*递归左边*/
quickSort(a,i+1,right);/*递归右边*/
}
不需要swap的Qsort,感觉还不错的说!
posted @
2008-10-31 11:20
SЁv⑦ēЙ
阅读(
81)
评论()
收藏
举报