From 1af9f4b881f37475eac2ed46c9afd3916edbe4e3 Mon Sep 17 00:00:00 2001 From: MamakinYR Date: Sat, 20 Apr 2024 00:55:06 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=92=D1=8B=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD=D0=B8=D0=BC=D1=83=D0=BC=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=BC=D0=B0=D0=BA=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 --- .gitignore | 3 ++- lab03.vcxproj | 6 +++--- lab1.cpp | 32 ++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 34134cf..452834f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /lab03.sln /lab03.vcxproj.filters /lab03.vcxproj.user -/.vs/ \ No newline at end of file +/.vs/ +/x64/ \ No newline at end of file diff --git a/lab03.vcxproj b/lab03.vcxproj index c04030b..3678d76 100644 --- a/lab03.vcxproj +++ b/lab03.vcxproj @@ -18,6 +18,9 @@ x64 + + + 17.0 Win32Proj @@ -126,9 +129,6 @@ true - - - diff --git a/lab1.cpp b/lab1.cpp index dd2f329..19e8e56 100644 --- a/lab1.cpp +++ b/lab1.cpp @@ -19,31 +19,35 @@ Input input_data() { 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; + } + if (x > max) + { + max = x; + } + } +} + int main() { const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; int i, j; - double num; + double min_number, max_number; Input in = input_data(); + find_minmax(in.numbers, min_number, max_number); vector bins(in.bin_count); for (i = 0; i < in.bin_count; i++) { bins[i] = 0; } - double min_number = in.numbers[0]; - double max_number = in.numbers[0]; - for (double x : in.numbers) - { - if (x < min_number) - { - min_number = x; - } - else if (x > max_number) - { - max_number = x; - } - } double bin_size = (max_number - min_number) / in.bin_count; for (size_t i = 0; i < in.numbers.size(); i++) {