#include #include "show_histogram.h" using namespace std; void show_histogram_text(const vector& bins) { //Находим максимум значений корзин int max_count = bins[0]; for (int x : bins) { if (x > max_count) max_count = x; } //Определяем надо ли масштабировать данные int K; if (max_count <= (MAX_STR_LNG - PREFIX)) { K = 0; } else { K = 1; } //Строим гистограмму int cnt; int bin_sz = bins.size(); for (int i = 0; i < bin_sz; i++) { cout.width(3); cout.fill(' '); cout << bins[i] << "|"; if (K == 0) cnt = bins[i]; else cnt = bins[i] * (MAX_STR_LNG - PREFIX) / max_count; for (double j = 0; j < cnt; j++) { cout << "*"; } cout << endl; } }