#include <iostream
void Merge(int c[]
{//合並c[l:m]和c[m+
int i=l
j=m+
k=l;
while((i<=m)&&(j<=r))
if(c[i]<=c[j]) d[k++]=c[i++];
else d[k++]=c[j++];
if(i>m)for(int q=j;q<=r;q++)
d[k++]=c[q];
else for(int q=i;q<=m;q++)
d[k++]=c[q];
}
void MergePass(int x[]
{//合並大小為s的相鄰子數組
int i=
while(i<=n
//合並大小為s的相鄰
Merge(x
i=i+
}
//剩余的元素個數少於
if(i+s<n) Merge(x
else for(int j=i;j<=n
y[j]=x[j];
}
void MergeSort(int a[]
{
int *b=new int [];
int s=
while(s<n){
MergePass(a
s+=s;
MergePass(b
s+=s;
}
}
int main()
{
int t[
cout<<
cout<<
int p=
int g=
while(g!=
cin>>g;
if(g!=
{ t[p]=g;
p++;
//g++;
}
}
/*for(int g=
cin>>t[g];*/
MergeSort(t
for(int i=
{
cout<<t[i]<<
}
return
}
From:http://tw.wingwit.com/Article/program/sjjg/201404/30582.html