code: разделение программы | вариант

master
KuzmenkoEA 12 месяцев назад
Родитель eb8fa30c2e
Сommit aafb80fb49

@ -1,32 +1,34 @@
#include <iostream>
#include "text.h" #include "text.h"
#include <iostream>
#include <vector>
using namespace std;
void show_histogram_text (const vector<double>& bins,size_t MAX_ASTERISK, size_t bin_count){
void
show_histogram_text (const std::vector<size_t>& bins){
size_t bin_max = 0; size_t bin_max = 0;
size_t height = 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 bin: bins) for (size_t i = bin_max; i > 0; i--)
{ {
size_t height = bin; for (size_t bin: bins)
height = MAX_ASTERISK * (static_cast<double>(bin) / bin_max);
if (bin < 100)
{
std::cout << " ";
}
if (bin < 10)
{ {
std::cout << " "; if (i <= bin)
{
cout << " * ";
}
else
{
cout << " ";
}
} }
std::cout << bin << "|"; cout << endl;
for (size_t i = 0; i < height; i++) }
{ for (size_t bin: bins) cout << " _ ";
std::cout << "*"; cout << "\n";
} for (size_t i = 0; i< bin_max; i++)
std::cout << std::endl; {
cout << " " << bins[i] << " ";
} }
} }

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