recording
#include<stdio.h>
int a[1000];
int b[1000];
void sort(int left, int mid, int right)
{
int pos_l = left;
int pos_r = mid+1;
int pos_new = left;
while (pos_l <= mid && pos_r <= right)
{
if (a[pos_l] < a[pos_r])
{
b[pos_new++] = a[pos_l++];
}
else
{
b[pos_new++] = a[pos_r++];
}
}
while (pos_l <= mid)
{
b[pos_new++] = a[pos_l++];
}
while (pos_r <= right)
{
b[pos_new++] = a[pos_r++];
}
while (left <= right)
{
a[left] = b[left];
left++;
}
}
void mergesort(int left, int right)
{
if (left < right)
{
int mid = (left + right) / 2;
mergesort(left, mid);
mergesort(mid + 1,right);
sort(left, mid, right);
}
}
int main()
{
int i, n;
scanf("%d", &n);
for (i = 0;i < n;i++)
{
scanf("%d", &a[i]);
}
mergesort(0, n - 1);
for (i = 0;i < n;i++)
{
printf("%d\t", a[i]);
}
}