KhatyukhinYS 1 год назад
Родитель fc08132081
Сommit 5f6b6bff82

@ -26,7 +26,6 @@ int main()
{
auto in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);
//show_histogram_text(bins,in.bin_count,in.numbers);
auto max_count=bins[0];
for(size_t x : bins){
if (x > max_count)
@ -34,6 +33,7 @@ int main()
max_count=x;
}
}
show_histogram_svg(bins, max_count);
show_histogram_text(bins,in.bin_count,in.numbers,max_count);
//show_histogram_svg(bins, max_count);
return 0;
}

@ -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);
}

@ -5,6 +5,6 @@
#include <iostream>
void
show_histogram_text(const std::vector<size_t> bins, size_t bin_count,const std::vector<double> numbers);
show_histogram_text(const std::vector<size_t> bins, size_t bin_count,const std::vector<double> numbers,size_t max_count);
#endif // TEXT_H_INCLUDED

Загрузка…
Отмена
Сохранить