From 204993639becc36b530a81a0353a73ceb4eaad57 Mon Sep 17 00:00:00 2001 From: BykovDA Date: Wed, 23 Apr 2025 17:36:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=B4=20=D0=B2=D0=BE=D0=B7=D0=B2?= =?UTF-8?q?=D1=80=D0=B0=D1=89=D0=B5=D0=BD=20=D0=BA=20=D0=B8=D0=B7=D0=BD?= =?UTF-8?q?=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC=D1=83=20=D0=B2?= =?UTF-8?q?=D0=B8=D0=B4=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 4cf9e6c..09e6406 100644 --- a/main.cpp +++ b/main.cpp @@ -41,20 +41,52 @@ int main() bins[bin_count-1]++; } } - for (size_t i = 0; i < number_count; i++) + size_t Maxbins = 0; + for (size_t i = 0; i < bin_count; i++) { - for (size_t j = 0; j < bin_count; j++) + if (bins[i] > Maxbins) { - if (bins[j]> i) + Maxbins = bins[i]; + } + } + const size_t MAX_HEIGHT = 76; + if (Maxbins <= MAX_HEIGHT) + { + for (size_t i = 0; i < bin_count; i++) + { + if (bins[i] < 10) + { + cout << " "; + } + cout << " " << bins[i]<< "|"; + for (size_t j = 0; j < bins[i]; j++) { cout << "*"; } - else + cout << endl; + } + } + else + { + for (size_t i = 0; i < bin_count; i++) + { + size_t height = static_cast(MAX_HEIGHT * (static_cast(bins[i]) / Maxbins)); + + if (bins[i] < 100) + { + cout << " "; + } + if (bins[i] < 10) { cout << " "; } + cout << bins[i] << "|"; + for (size_t j = 0; j < height; j++) + { + cout << "*"; + } + cout << endl; } - cout << endl; } return 0; }