#include "text.h" #include #include using namespace std; void show_histogram_text (const vector& bins, size_t MAX_ASTERISK, size_t bin_count){ double max_count = bins[0]; for (double x: bins){ if (x > max_count) { max_count = x; } } for (int i = 0; i < bin_count; i++){ double count = bins[i]; size_t height = MAX_ASTERISK * (static_cast(count) / max_count); string line (height , '*'); if (bins[i]<100) {cout << ' ';} if (bins[i]<10) {cout << ' ';} cout << bins[i] << "|" << line << endl; } }