排序-mergesort
作者:互联网
void merge(int l,int r)
{
if(l>=r) return ;
int mid=(l+r)>>1;
merge(l,mid);
merge(mid+1,r);
int i=l,j=mid+1,k=0;
while(i<=mid&&j<=r){
if(a[i]<=a[j]) b[k++]=a[i++];
else b[k++]=a[j++];
}
while(i<=mid) b[k++]=a[i++];
while(j<=r) b[k++]=a[j++];
for(int ii=0;ii<k;ii++) a[ii+l]=b[ii];
return ;
}
标签:mergesort,return,int,++,mid,merge,while,排序 来源: https://www.cnblogs.com/fengzlj/p/15962313.html