Родитель
e9ae32af33
Сommit
9569393aea
@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
#include "text.h"
|
||||
|
||||
|
||||
void
|
||||
show_histogram_text (const std::vector<size_t>& bins){
|
||||
size_t bin_max = 0;
|
||||
size_t height = 0;
|
||||
for (double y : bins)
|
||||
{
|
||||
if (y > bin_max){bin_max = y;}
|
||||
}
|
||||
for (size_t bin: bins)
|
||||
{
|
||||
size_t height = bin;
|
||||
height = MAX_ASTERISK * (static_cast<double>(bin) / bin_max);
|
||||
if (bin < 100)
|
||||
{
|
||||
std::cout << " ";
|
||||
}
|
||||
if (bin < 10)
|
||||
{
|
||||
std::cout << " ";
|
||||
}
|
||||
std::cout << bin << "|";
|
||||
for (size_t i = 0; i < height; i++)
|
||||
{
|
||||
std::cout << "*";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче