#include #include #include "text.h" using namespace std; void show_histogram_text(const vector& bins) { const size_t screen_width = 80; const size_t max_asterisk = screen_width - 4; size_t max_count = 0; for (size_t count : bins) { if (count > max_count) { max_count = count; } } for (size_t bin : bins) { if (bin < 100) { cout << ' '; } if (bin < 10) { cout << ' '; } cout << bin << "|"; size_t height = max_asterisk * (static_cast(bin) / max_count); for (size_t i = 0; i < height; i++) { cout << '*'; } cout << '\n'; } }