From 92f5f13668da8581356b3442df46555453294a05 Mon Sep 17 00:00:00 2001 From: MakhnovGA Date: Mon, 22 May 2023 14:48:27 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D1=83?= =?UTF-8?q?=D1=8E=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=83?= =?UTF-8?q?=D1=8E=20promt=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=20=D0=BF=D1=80=D0=B8=D0=B3=D0=BB=D0=B0=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- histogram.cpp | 10 +--------- histogram_internal.h | 1 - lab_01.depend | 10 +++++----- main.cpp | 23 +++++++++-------------- svg.cpp | 13 +------------ svg.h | 2 +- 6 files changed, 17 insertions(+), 42 deletions(-) diff --git a/histogram.cpp b/histogram.cpp index 01ecc45..ad42d3f 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -48,12 +48,4 @@ vector make_histogramm(vectornumbers, size_t bin_count){ } else cerr << "Empty massive of numbers"; -} -bool check_interval(size_t interval){ - bool need; - if (interval > 9 || interval < 2) - need = false; - else - need = true; - return need; -} + } diff --git a/histogram_internal.h b/histogram_internal.h index 538fba9..00784db 100644 --- a/histogram_internal.h +++ b/histogram_internal.h @@ -3,5 +3,4 @@ #include bool find_minmax(std::vector numbers, double &min, double &max); -bool check_interval(size_t interval); #endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/lab_01.depend b/lab_01.depend index 1b59b37..7d24bf2 100644 --- a/lab_01.depend +++ b/lab_01.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1682340368 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\histogram.cpp +1684755837 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\histogram.cpp @@ -10,7 +10,7 @@ 1682341619 c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\histogram.h -1682338657 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\main.cpp +1684755828 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\main.cpp @@ -30,12 +30,12 @@ "text.h" -1682339360 c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\histogram_internal.h +1684755787 c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\histogram_internal.h -1682183926 c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\svg.h +1684755829 c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\svg.h -1682337971 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\svg.cpp +1684755829 source:c:\users\gmack\onedrive\рабочий стол\lab01\lab_01\svg.cpp diff --git a/main.cpp b/main.cpp index 27c1d23..56a63d3 100644 --- a/main.cpp +++ b/main.cpp @@ -15,33 +15,28 @@ struct Input { }; Input -input_data(istream &tin){ - cerr << "Input numbers count: "; +input_data(istream &tin, bool prompt){ + if (prompt) + cerr << "Input numbers count: "; size_t number_count; tin >> number_count; Input in; in.numbers.resize(number_count); - cerr << "Input numbers: "; + if (prompt) + cerr << "Input numbers: "; for (size_t i = 0; i < number_count; i++) { tin >> in.numbers[i]; } - cerr << "Input bin count: "; + if (prompt) + cerr << "Input bin count: "; tin >> in.bin_count; return in; } int main() { - Input in = input_data(cin); + Input in = input_data(cin, false); auto bins = make_histogramm(in.numbers, in.bin_count); - size_t interval; - cerr << "Input interval: "; cin >> interval; - bool inRange; - inRange = check_interval(interval); - if (!inRange){ - cerr << "ERROR"; - return 0; - } - show_histogram_svg(bins, interval); + show_histogram_svg(bins); return 0; } diff --git a/svg.cpp b/svg.cpp index ad09db9..fa4801f 100644 --- a/svg.cpp +++ b/svg.cpp @@ -31,7 +31,7 @@ void svg_rect(double x, double y, double width, double height, string colour = " } void -show_histogram_svg(const vector& bins, size_t interval) { +show_histogram_svg(const vector& bins) { const auto IMAGE_WIDTH = 400; const auto IMAGE_HEIGHT = 300; const auto TEXT_LEFT = 20; @@ -52,16 +52,5 @@ show_histogram_svg(const vector& bins, size_t interval) { svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "green", "#FF00FF"); top += BIN_HEIGHT; } - top+=BIN_HEIGHT; - const size_t SPACE = 2; - double max_width = (IMAGE_WIDTH - TEXT_WIDTH); - const double block = max_width/max_count; - for (size_t i = 0; i& bins, size_t interval); +show_histogram_svg(const std::vector& bins); #endif // SVG_H_INCLUDED