#include "text.hpp" #include const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; void show_histogram_text(std::vector bins, size_t bin_count) { double max_bin = *std::max_element(bins.begin(), bins.end()); for (size_t i = 0; i < bin_count; i++) { if (bins[i] < 100) std::cout << " "; if (bins[i] < 10) std::cout << " "; std::cout << bins[i] << "|"; size_t height = MAX_ASTERISK * (static_cast(bins[i]) / max_bin); for (size_t j = 0; j < height; j++) { std::cout << "*"; } std::cout << std::endl; } }