#include<cstdio>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int n;
int tmp[N];
void merge_sort(int* a, const int& left, const int& right)
{
if(left >= right) return;
int mid = (left + right) >> 1;
merge_sort(a, left, mid);
merge_sort(a, mid + 1, right);
int k(0), i(left), j(mid + 1);
while(i <= mid && j <= right)
{
if(a[i] <= a[j]) tmp[k++] = a[i++];
else tmp[k++] = a[j++];
}
while(i <= mid) tmp[k++] = a[i++];
while(j <= right) tmp[k++] = a[j++];
for(i = left, j = 0; i <= right;) a[i++] = tmp[j++];
}
int main(void)
{
scanf("%d",&n);
for(int i(0);i<n;++i) scanf("%d",&a[i]);
merge_sort(a,0,n-1);
for(int i(0);i<n;++i) printf("%d ",a[i]);
return 0;
}
03-25
1679
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)