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