From b2da1775b1bd8105ab15a3402e147717e5204f00 Mon Sep 17 00:00:00 2001 From: victoriaCS Date: Sun, 18 May 2025 14:10:19 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=B0=20pro?= =?UTF-8?q?mpt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index dbb0370..125747c 100644 --- a/main.cpp +++ b/main.cpp @@ -12,18 +12,27 @@ struct Input { size_t block_width{}; }; -Input input_data(istream& in_steam = cin) { - cerr << "Enter number count: "; - cin >> number_count; +Input input_data(istream& in_steam = cin, bool prompt = true) { + size_t number_count; + if (prompt) { + cerr << "Enter number count: "; + } + in_steam >> number_count; Input in; in.numbers.resize(number_count); + if (prompt) { + cerr << "Enter " << number_count << " numbers: "; + } for (size_t i = 0; i < number_count; i++) { - cin >> in.numbers[i]; + in_stream >> in.numbers[i]; + } + + if (prompt) { + cerr << "Enter bin count: "; } - cerr << "Enter bin count: "; - cin >> in.bin_count; + in_stream >> in.bin_count; return in; }