From 29ff79baf2e66e8e265d68d762345641b7e19c06 Mon Sep 17 00:00:00 2001 From: TiutinMO Date: Sun, 15 Jun 2025 00:47:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histogram.cpp | 8 +++++++- main.cpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/histogram.cpp b/histogram.cpp index 5d85960..641db08 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -3,8 +3,14 @@ using namespace std; void find_minmax(const vector& numbers, double& min, double& max) { + if (numbers.empty()) + { + min = 0; + max = 0; + return; + } max = numbers[0]; - min = numbers[1]; + min = numbers[0]; for (double x : numbers) { if (x < min) min = x; else if (x > max) max = x; diff --git a/main.cpp b/main.cpp index 2db886d..7e40a09 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include #include "histogram.h" #include "text.h" +#include "svg.h" using namespace std; struct Input { @@ -14,6 +15,7 @@ Input input_data() { size_t number_count; cerr << "Enter number count: "; cin >> number_count; + in.numbers.resize(number_count); cerr << "Enter numbers: "; for (size_t i = 0; i < number_count; i++) { @@ -28,6 +30,6 @@ Input input_data() { int main() { auto in = input_data(); auto bins = make_histogram(in.numbers, in.bin_count); - show_histogram_text(bins, in.bin_count); + show_histogram_svg(bins); return 0; }