#include <iostream>
using namespace std;
void countSort(int arr[], int len, int orderedArr[]) {
int *count = new int(len);
for (int i = 0; i < len; ++i) {
count[i] = 0;
}
for (int i = 0; i < len; ++i) {
for (int j = i+1; j < len; ++j) {
if (arr[i] > arr[j]) {
++count[i];
}
else {
++count[j];
}
}
}
for (int i = 0; i < len; ++i) {
orderedArr[count[i]] = arr[i];
}
}
void printArray(int arr[], int len) {
for (int i = 0; i < len; ++i) {
cout << arr[i] << " ";
}
cout << endl;
}
int main() {
int arr[] = {62, 31, 84, 96, 19, 47};
int orderedArr[6];
printArray(arr, 6);
countSort(arr, 6, orderedArr);
printArray(orderedArr, 6);
}