#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 arr1[] = {62, 31, 84, 96, 19, 47};
int orderedArr1[6];
printArray(arr1, 6);
countSort(arr1, 6, orderedArr1);
printArray(orderedArr1, 6);
int arr2[] = {11, 54, 23, 48, 88, 24};
int orderedArr2[6];
cout << "=========================================" << endl;
printArray(arr2, 6);
countSort(arr2, 6, orderedArr2);
printArray(orderedArr2, 6);
}