#include<stdio.h>
#include<conio.h>
#include
#include<stdlib.h>
using namespace std;
int p[10]={31,2,15,3,77,12,89,98,43,34},q[10],k;
void merge(int,int,int,int);
void partition(int,int);
int main()
{
int i;
partition(0,9);
for(i=0;i<=9;i++)
{
cout<<p[i]<<endl;
}
return 0;
}
void partition(int x, int y)
{
if(x!=y)
{
k=(x+y)/2;
partition(x,k);
partition(k+1,y);
merge(x,k,k+1,y);
}
}
void merge(int a, int b, int c, int d)
{
int k=a,t=d;
int i;
for(i=k;i<=t;i++)
{
if(p[a]>p[c])
{
q[i]=p[c];
c++;
}
else
{
q[i]=p[a];
a++;
}
}
if(a<=b)
q[d]=p[b];
else
q[d]=p[d];
for(i=0;i<=9;i++)
{
p[i]=q[i];
}
}