|
|
|
@ -7,25 +7,34 @@ using namespace std;
|
|
|
|
|
const size_t SCREEN_WIDTH = 80;
|
|
|
|
|
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
|
|
|
|
|
|
|
|
|
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const std::vector<double> numbers)
|
|
|
|
|
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const std::vector<double> numbers,size_t max_count)
|
|
|
|
|
{
|
|
|
|
|
size_t procent=100;
|
|
|
|
|
for(size_t i = 0;i<(bin_count-1);i++){
|
|
|
|
|
double number = numbers.size();
|
|
|
|
|
//cout<<number;
|
|
|
|
|
double proc=(bins[i]/number)*100;
|
|
|
|
|
procent -=round(proc);
|
|
|
|
|
printf("%3.0f%%:", proc);
|
|
|
|
|
printf("%3d:", bins[i]);
|
|
|
|
|
for(size_t j = 0;j<bins[i];j++)
|
|
|
|
|
{
|
|
|
|
|
cout<<"*";
|
|
|
|
|
}
|
|
|
|
|
for(size_t g=0;g<(max_count-bins[i]);g++)
|
|
|
|
|
{
|
|
|
|
|
cout<<" ";
|
|
|
|
|
}
|
|
|
|
|
printf("%3.0f%%",proc);
|
|
|
|
|
cout<<endl;
|
|
|
|
|
}
|
|
|
|
|
//procent=Math.round(procent);
|
|
|
|
|
printf("%3d%%:",procent);
|
|
|
|
|
printf("%3d:",bins[bin_count-1]);
|
|
|
|
|
for(size_t j = 0;j<bins[bin_count - 1];j++)
|
|
|
|
|
{
|
|
|
|
|
cout<<"*";
|
|
|
|
|
}
|
|
|
|
|
for(size_t g=0;g<(max_count-bins[bin_count-1]);g++)
|
|
|
|
|
{
|
|
|
|
|
cout<<" ";
|
|
|
|
|
}
|
|
|
|
|
printf("%3d%%",procent);
|
|
|
|
|
}
|
|
|
|
|