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