From 77f57ea9f36f21dfad89e41dbf1e613b3f60f62c Mon Sep 17 00:00:00 2001 From: OvsiannikovRS Date: Sun, 25 May 2025 22:10:03 +0300 Subject: [PATCH] =?UTF-8?q?code:=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LR3/main.cpp | 49 ++----------------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/LR3/main.cpp b/LR3/main.cpp index 0e842d3..289053a 100644 --- a/LR3/main.cpp +++ b/LR3/main.cpp @@ -1,5 +1,7 @@ #include #include +#include "histogram.h" +#include "text.h" using namespace std; @@ -22,54 +24,7 @@ input_data(){ return in; } -void -find_minmax(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; - } - } -} - -vector -make_histogram(vector numbers, int bin_count){ - vector bins(bin_count); - double min = numbers[0]; - double max = numbers[0]; - find_minmax(numbers, min, max); - double bin_size = (max - min) / bin_count; - for (auto x: numbers) { - bool found = false; - for (size_t j = 0; (j < bin_count - 1) && !found; j++) { - auto lo = min + j * bin_size; - auto hi = min + (j + 1) * bin_size; - if ((lo <= x) && (x < hi)) { - bins[j]++; - found = true; - } - } - if (!found) { - bins[bin_count - 1]++; - } - } - return bins; -} -void -show_histogram_text(vector bins){ - for(size_t count: bins){ - if (count < 100) cout << " "; - if (count < 10) cout << " "; - cout << count << "|"; - for(size_t i = 0; i < count; ++i) cout << "*"; - cout << "\n"; - } -} int main() {