归并排序
#include<iostream>
using namespace std;
const int a=1e6+10;
int q[a],t[a];
void margin_sort(int q[],int l,int r)
{ if(l>=r)return;
int mid=(l+r)/2;
mergin_sort(q,l,mid);
mergin_sort(q,mid+1,r);
int i=l,j=mid+1,f=0;
while(i<=mid&&j<=r){
if(q[i]<=q[j])t[f++]=q[i++];
else t[f++]=q[j++];
}
while(i<=mid)t[f++]=q[i++];
while(j<=r)t[f++]=q[j++];
for(int i=l,j=0;i<=r;i++,j++)q[i]=t[j];
}
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%d",&q[i]);
mergin_sort(q,0,n-1);
for(int i=0;i<n;i++)printf("%d ",q[i]);
return 0;
}