#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void BucketSort(int *arr,int len,int max)
{
int *bucket;
int i;
int cnt=0;
bucket=(int*)malloc(sizeof(int) * max);
memset(bucket,0,sizeof(int)*max);
for(i=0;i<len;i++)
{
bucket[arr[i]]++;
}
for(i=0;i<max;i++)
{
while(bucket[i]--)
{
arr[cnt++]=i;
}
}
}
int main()
{
int arr[]={1,5,2,7,12,5,1,7,2,1,7,0,12,5,3,4,6,1};
int len=(int)(sizeof(arr)/sizeof(int));
BucketSort(arr,len,20);
for(int i=0;i<len;i++)
{
if(i) putchar(' ');
printf("%d",arr[i]);
}
return 0;
}