1#include <iostream>
2#define MAX 100
3using namespace std;
4void Merge(int A[], int START, int MID, int END) {
5 int LA[MAX], RA[MAX], I, L = 0, R = 0;
6 for (I = START; I <= MID; I++)
7 LA[I - START] = A[I];
8 LA[I - START] = INT_MAX;
9 for (I = MID + 1; I <= END; I++)
10 RA[I - MID - 1] = A[I];
11 RA[I - MID - 1] = INT_MAX;
12 for (I = START; I <= END; I++)
13 if (LA[L] < RA[R])
14 A[I] = LA[L++];
15 else
16 A[I] = RA[R++];
17}
18void MergeSort(int A[], int START, int END) {
19 if (START < END) {
20 int MID = (START + END) / 2;
21 MergeSort(A, START, MID);
22 MergeSort(A, MID + 1, END);
23 Merge(A, START, MID, END);
24 }
25}
26void main() {
27 int A[MAX], n, I;
28 cin >> n;
29 for (I = 0; I < n; I++)
30 cin >> A[I];
31 MergeSort(A, 0, n - 1);
32 for (I = 0; I < n; I++)
33 cout << A[I] << " ";
34}