From 09c3eb56feac0fe4e19c0f4031e63a7a3280eb57 Mon Sep 17 00:00:00 2001 From: YusufovYB Date: Mon, 22 May 2023 10:01:18 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=BB=D1=8E=D0=B1=D1=8B=D0=BC=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=20=D0=B8=20=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20input=5Fdata=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=20bool=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chtoto.cbp | 6 ++++++ main.cpp | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/chtoto.cbp b/chtoto.cbp index e3425c8..e39e670 100644 --- a/chtoto.cbp +++ b/chtoto.cbp @@ -32,7 +32,13 @@ + + + + + + diff --git a/main.cpp b/main.cpp index bc83488..aec7f45 100644 --- a/main.cpp +++ b/main.cpp @@ -10,25 +10,28 @@ struct Input { size_t bin_count{}; }; -Input input_data() +Input input_data(istream& in, bool prompt) { size_t number_count; - cerr << "Enter number count = "; - cin >> number_count; - Input in; - in.numbers.resize(number_count); + if (prompt) + cerr << "Enter number count = "; + + in >> number_count; + Input inn; + inn.numbers.resize(number_count); for (size_t i = 0; i < number_count; i++) { - cin >> in.numbers[i]; + in >> inn.numbers[i]; } - cerr << "Enter bin_count = "; - cin >> in.bin_count; - return in; + if (prompt) + cerr << "Enter bin_count = "; + in >> inn.bin_count; + return inn; } int main() { - auto in = input_data(); + auto in = input_data(cin, true); auto bins = make_histogram(in.numbers, in.bin_count); show_histogram_svg(bins);