I've got my counting sort to work with an array that I filled with numbers. Now I want to make it so I am taking the information from an input file. I will have input files with very large amounts of numbers (ranging from 0 - 4000). I will also have the number of items in that file given to me. How would I adjust this code to work for any input file?
int array[10]={5,5,5,5,5,5,1,2,5,7};
int count_array[10]={0};
int sum=0;
int new_array[10];
int i;
for(i=0;i<10;i++)
count_array[array[i]]++;
for(i=0;i<10;i++)
{
count_array[i]=count_array[i]+sum;
sum=count_array[i];
}
for(i=0;i<10;i++)
{
new_array[count_array[array[i]]]=array[i];
count_array[array[i]]--;
}
for(i=1;i<=10;i++)
{
cout<<new_array[i]<<" ";
}
cout<<endl;