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; }