From 686c2de87a968ca8766fac607234fe2bece8320b Mon Sep 17 00:00:00 2001 From: KlimenchenkoIA Date: Mon, 28 Apr 2025 14:37:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BC=D0=B8=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=D1=83=D0=BC=D0=B0=20=D0=B8=20=D0=BC=D0=B0=D0=BA?= =?UTF-8?q?=D1=81=D0=B8=D0=BC=D1=83=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/main.cpp b/main.cpp index 12bf256..a5044e3 100644 --- a/main.cpp +++ b/main.cpp @@ -23,11 +23,27 @@ Input input_data() cin >> in.bin_count; return in; } +void find_minmax(const vector& numbers, double& min, double& max) { + min = numbers[0]; + max = numbers[0]; + for (double x : numbers) + { + if (x < min) + { + min = x; + } + else if (x > max) + { + max = x; + } + } +} int main() { const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; Input in = input_data(); + // size_t number_count; cerr << "Enter number count: "; cin >> number_count; @@ -42,21 +58,23 @@ int main() size_t bin_count; cerr << "Enter bin count: "; cin >> bin_count; + // vector bins(bin_count, 0); - - double min = numbers[0]; - double max = numbers[0]; - for (double x : numbers) - { - if (x < min) - { - min = x; - } - else if (x > max) - { - max = x; - } - } +double min, max; +find_minmax(in.numbers, min, max); + // double min = numbers[0]; + // double max = numbers[0]; + //for (double x : numbers) + // { + // if (x < min) + // { + // min = x; + // } + // else if (x > max) + // { + // max = x; + // } + // } double bin_size = (max - min) / bin_count;