#include "text.h" #include #include using namespace std; void show_histogram_text(vector& bins, size_t & max_count,size_t & bin_count) { const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; if (max_count > MAX_ASTERISK){ vector hights(bin_count); for (size_t i = 0; i < bin_count; i++){ size_t height = MAX_ASTERISK * (static_cast(bins[i]) / max_count); hights[i] = height; } for (size_t i = 0; i < bin_count; i++){ printf("%3d|", bins[i]); for (size_t j = 0; j < hights[i]; j++){ cout<<"*"; } cout << endl; } } else{ for (size_t i = 0; i < bin_count; i++) { printf("%3d|", bins[i]); for (size_t j = 0; j < bins[i]; j++){ cout<<"*"; } cout << endl; } } }