From b2844426112e6cf75b5c632ef56239152d3cc05e Mon Sep 17 00:00:00 2001 From: "Alice (VasinaEY)" Date: Sun, 1 Jun 2025 19:51:40 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B8=20bo?= =?UTF-8?q?ol=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 1c8fa73..c2ec29a 100644 --- a/main.cpp +++ b/main.cpp @@ -9,21 +9,28 @@ struct Input { size_t bin_count{}; }; -Input input_data(std::istream& in) { +Input input_data(std::istream& in, bool prompt) { Input data; size_t number_count; + if(prompt){ cerr << "Enter the number of elements: "; - in >> number_count; + } + in >> number_count; data.numbers.resize(number_count); + if(prompt){ cerr << "\nEnter " << number_count << " elements:" << endl; + } + for (size_t i = 0; i < number_count; i++) { in >> data.numbers[i]; } - + if(prompt){ cerr << "Enter the number of bins: "; + } + in >> data.bin_count; return data; @@ -31,7 +38,7 @@ Input input_data(std::istream& in) { int main() { using namespace std; - auto in = input_data(cin); + auto in = input_data(cin,true); auto bins = make_histogram(in.bin_count, in.numbers); show_histogram_svg(bins); return 0;