From 1bc46ea9461adc0baa7e30d3eb2d2ca235699fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=BE=D0=BD=D0=BE=D0=B2=20=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Sat, 22 Apr 2023 18:28:18 +0300 Subject: [PATCH] =?UTF-8?q?Code:=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20-=20=D0=BF=D0=BE=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=20min=20=D0=B8=20max=20=D0=B2=D1=8B=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=83=D1=8E=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 07ee2a6..9289174 100644 --- a/main.cpp +++ b/main.cpp @@ -25,13 +25,11 @@ Input input_data() return in; } -int main() +void find_minmax(const std::vector& numbers, double &min, double &max) { - Input in = input_data(); - std::vector bins(in.bin_count); - double min = in.numbers[0]; - double max = in.numbers[0]; - for (double x : in.numbers) + min = numbers[0]; + max = numbers[0]; + for (double x : numbers) { if (x < min) { @@ -42,7 +40,14 @@ int main() max = x; } } +} +int main() +{ + Input in = input_data(); + std::vector bins(in.bin_count); + double min, max; + find_minmax(in.numbers, min, max); double bin_size = (max - min) / in.bin_count; for (size_t i = 0; i < in.numbers.size(); i++)