Professional Documents
Culture Documents
Countsort C
Countsort C
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<stdio.h>
for(i=0;i<n;++i)
count[a[i]]=count[a[i]]+1;
int main()
{
int a[50],n,i,max=0;
printf("Enter number of elements:");
scanf("%d",&n);
printf("\nEnter elements:");
for(i=0;i<n;++i)
{
scanf("%d",&a[i]);
if(a[i]>max)
max=a[i];
}
counting_sort(a,n,max);
return 0;
}