#include #include "text.h" using namespace std; const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH -3 -1; void show_histogram_text(const vector& bins) { size_t max_count = 0; for (size_ count : bins) { if (count > max_count) { max_count = count; } } for (size_t count :bins) { if (count <10) { cout << " " << cout <<"|"; } else if (count < 100) { cout<<" " << cout << "|"; } if (count <1000) { cout << cout <<"|"; } size_t height; if (max_count <= MAX_ASTERISK) { height=count; } else { height = static_cast(MAX_ASTERISK*(static_cast(count)/ max_count)); } for (size_t j = 0; j< height ; j++) { cout << "*"; } cout << endl; } }