#include<iostream>
#include <stdio.h>
using namespace std;
#define N 7
#define MAX 100
int getMax(int list[]) {
int i, max = list[0];
for (i = 1; i < N; i++) {
if (list[i] > max)
max = list[i];
}
return max;
}
void countingSort(int list[]) {
int i;
int max = getMax(list);
int array[MAX] = { 0 };
int output[N] = { 0 };
for (i = 0; i < N; i++) {
array[list[i]]++;
}
for (i = 1; i <= max; i++) {
array[i] += array[i - 1];
}
for (i = N - 1; i >= 0; i--) {
output[array[list[i]] - 1] = list[i];
array[list[i]]--;
}
for (i = 0; i < N; i++) {
list[i] = output[i];
}
}
void printlist(int list[]) {
int i;
for (i = 0; i < N; ++i) {
printf("%d ", list[i]);
}
}
int main() {
int list[] = {2,5,3,0,3,0,3};
countingSort(list);
printlist(list);
}