From 0345f44bfcbd7e051d1a2bff00c4502f047c3c9e Mon Sep 17 00:00:00 2001 From: "lab01(PokhilAA)" Date: Sun, 5 May 2024 16:34:40 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D1=84=D0=B0=D0=B9=D0=BB=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- text.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 text.cpp 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; + } +}