From aafb80fb49b0a4358cba4ef6b3ff539be2eb6398 Mon Sep 17 00:00:00 2001 From: KuzmenkoEA Date: Sun, 5 May 2024 23:36:42 +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=20|=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- text.cpp | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/text.cpp b/text.cpp index d8d3121..2411c33 100644 --- a/text.cpp +++ b/text.cpp @@ -1,32 +1,34 @@ -#include #include "text.h" +#include +#include +using namespace std; - -void -show_histogram_text (const std::vector& bins){ +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 y : bins) + for (double x : bins) { - if (y > bin_max){bin_max = y;} + if (x > bin_max){bin_max = x;} } - for (size_t bin: bins) + for (size_t i = bin_max; i > 0; i--) { - size_t height = bin; - height = MAX_ASTERISK * (static_cast(bin) / bin_max); - if (bin < 100) - { - std::cout << " "; - } - if (bin < 10) + for (size_t bin: bins) { - std::cout << " "; + if (i <= bin) + { + cout << " * "; + } + else + { + cout << " "; + } } - std::cout << bin << "|"; - for (size_t i = 0; i < height; i++) - { - std::cout << "*"; - } - std::cout << std::endl; + cout << endl; + } + for (size_t bin: bins) cout << " _ "; + cout << "\n"; + for (size_t i = 0; i< bin_max; i++) + { + cout << " " << bins[i] << " "; } }