#include<stdio.h>
#include<stdlib.h>
int K[] ={5,6,7,15,20,3,45,9,18};
int sz = sizeof(K) / sizeof(K[0]);
void Merge(int a[], int low, int mid, int high) {
int* b = (int*)malloc(sz*sizeof(int));
int i, j, k;
for (k = low; k <= high; k++)
b[k] = a[k];
for (i = low, j = mid + 1, k = i; i <= mid && j <= high; k++) {
if (b[i] < b[j])
a[k] = b[i++];
else
a[k] = b[j++];
}
while (i <= mid){
a[k++] = b[i++];
}
while (j <= high){
a[k++] = b[j++];
}
}
void Merge_Sort(int a[], int low, int high) {
if (low < high) {
int mid = (low + high) / 2;
Merge_Sort(a, low, mid);
Merge_Sort(a, mid + 1, high);
Merge(a, low, mid, high);
}
}
int main() {
Merge_Sort(K, 0, sz-1);
for (int i = 0; i < sz; i++)
printf("%d ", K[i]);
}