From 9569393aead0e6dc125cd4d47160076968c30d9f Mon Sep 17 00:00:00 2001 From: KuzmenkoEA Date: Sun, 21 Apr 2024 19:46:31 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=BC=D1=8B=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- text.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 text.cpp 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 +#include "text.h" + + +void +show_histogram_text (const std::vector& 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(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; + } +}