From f0211976588077a9f569e8153c8db4d1f11c2255 Mon Sep 17 00:00:00 2001 From: "PARZIVAL (BreganIM)" Date: Thu, 8 May 2025 17:37:33 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B2=20input=5Fdata=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BD=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20boo?= =?UTF-8?q?l=20promt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- laba01upd3.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/laba01upd3.cpp b/laba01upd3.cpp index 4f427d5..5b0fb6d 100644 --- a/laba01upd3.cpp +++ b/laba01upd3.cpp @@ -12,21 +12,36 @@ struct Input { size_t bin_count{}; }; -Input input_data(istream& in_stream) { +Input input_data(istream& in_stream, bool prompt) { Input in; size_t number_count; + + if (prompt) { + cerr << "Enter number count: "; + } in_stream >> number_count; + in.numbers.resize(number_count); + if (prompt) { + cerr << "Enter " << number_count << " numbers: "; + } for (size_t i = 0; i < number_count; i++) { in_stream >> in.numbers[i]; } + + if (prompt) { + cerr << "Enter bin count: "; + } in_stream >> in.bin_count; + return in; } + int main(int argc, char* argv[]) { - auto in = input_data(cin); + bool prompt = true; + auto in = input_data(cin, prompt); auto bins = make_histogram(in.numbers, in.bin_count); show_histogram_svg(bins); show_histogram_text(bins);