(简单的快速排序)需要改正
#include <iostream.h>int sum=0;
void fu(int a[],int left,int right)
{
int i,j,mid,t;
mid=a[(left+right)/2];
do
{
for(i=left;i<=(left+right)/2;i++)
{
if(a[i]>=mid)
break;
}
for(j=right;j>=(left+right)/2;j--)
{
if(a[j]<=mid)
break;
}
t=a[i];
a[i]=a[j];
a[j]=t;
sum+=1;
}
while(i<=j);
if(left<j)
fu(a,left,j);
if(right>i)
fu(a,i,right);
}
void quitsort(int a[],int n)
{
fu(a,0,n-1);
cout<<"QUITSORT排序次数为:\t"<<sum;
cout<<endl;
}
[此贴子已经被作者于2007-7-2 17:00:49编辑过]