diff --git a/text.cpp b/text.cpp new file mode 100644 index 0000000..2c4a391 --- /dev/null +++ b/text.cpp @@ -0,0 +1,34 @@ +#include "text.h" +#include +using namespace std; + +void +show_histogram_text (const vector& bins,size_t MAX_ASTERISK, size_t bin_count){ + size_t bin_max = 0; + size_t height = 0; + for (double x : bins) + { + if (x > bin_max){ + bin_max = x; + } + } + for (size_t bin: bins) + { + size_t height = bin; + height = MAX_ASTERISK * (static_cast(bin) / bin_max); + if (bin < 100) + { + cout << " "; + } + if (bin < 10) + { + cout << " "; + } + cout << bin << "|"; + for (size_t i = 0; i < height; i++) + { + cout << "*"; + } + cout << endl; + } +}