#include
#include
#include
using namespace std;
void printArray(int *a,int n)
{
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
int* countSort(int *a,int n)
{
int range=*max_element(a,a+n);
cout<<“1. range:”<<range;
int *count;
memset(count,0,range);
for(int i=0;i<range;i++)
cout<<"2. initialize to 0:"<<*(count+i);
for(int i=0;i<n;i++)
count[a[i]]++;
for(int i=0;i<range;i++)
cout<<"2. initialize to 0:"<<*(count+i);
for(int i=0;i<range;i++)
count[i]+=count[i-1];
for(int i=0;i<range;i++)
cout<<"2. initialize to 0:"<<*(count+i);
int b[n];
for(int i=n;i>=1;i--)
{
b[count[a[i]]]=a[i];
count[a[i]]-=1;
}
return b;
}
int main()
{
int n,a[100];
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
printArray(a,n);
int*b=countSort(a,n);
printArray(b,n);
}
Not able to get any output for b and count array