From 4c0d8fe93bc9a97afd298b504574a5edd5d1a94a Mon Sep 17 00:00:00 2001 From: StepanovaKY Date: Sun, 18 May 2025 13:16:46 +0300 Subject: [PATCH] =?UTF-8?q?Code:=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80?= =?UTF-8?q?=D0=B0=20Imput=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/main.cpp b/main.cpp index b568345..8016909 100644 --- a/main.cpp +++ b/main.cpp @@ -5,39 +5,38 @@ using namespace std; -struct Input{ +struct Input { vector numbers; size_t bin_count{}; +}; -} - - -Input input_data(){ +// Обновленная функция 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); - - for(size_t i=0; i>in.numbers[i]; + if (prompt) { + cerr << "Enter number count: "; } + in >> number_count; - cerr<<"Enter bin count: "; - cin>>in.bin_count; - return in; -} + Input input; + input.numbers.resize(number_count); + for (size_t i = 0; i < number_count; i++) { + in >> input.numbers[i]; + } + if (prompt) { + cerr << "Enter bin count: "; + } + in >> input.bin_count; -int main(){ + return input; +} - auto in = input_data(); +int main() { + // Вызываем input_data с cin и указанием вывода подсказок + auto in = input_data(cin, true); auto bins = make_histogram(in.numbers, in.bin_count); show_histogram_svg(bins); - - } -