#include #include #include #include #include "text.h" using namespace std; void show_histogram_text(size_t& bin_count, vector& bins){ vector counts(bin_count); for (size_t i = 0; i < bin_count; i++){ for (size_t j = 0; j < bins[i]; j++){ counts[i]++; } } size_t max_count = counts[0]; for (size_t i=0; imax_count){ max_count = counts[i]; } } const size_t screen_width = 80; const size_t max_asterisk = screen_width - 3 - 1; vector heights(bin_count); size_t height; for (size_t i=0; i 76){ height = (max_asterisk*(static_cast(counts[i])/max_count)); } else { height = counts[i]; } heights[i] = height; } for (size_t i = 0; i < bin_count; i++){ if(bins[i]<100){ cout << " "; } if (bins[i]<10){ cout << " "; } cout << bins[i] << "|"; for (size_t j = 0; j < heights[i]; j++){ cout << "*"; } cout << "\n"; } }