From 0db6012850092ca07acdf4374da8c2ebfa41fc2f Mon Sep 17 00:00:00 2001 From: "laba34 (BuntovaMS)" Date: Mon, 2 Jun 2025 11:57:03 +0300 Subject: [PATCH] bool prompt --- main.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index c6d45a3..eeb773d 100644 --- a/main.cpp +++ b/main.cpp @@ -8,21 +8,29 @@ 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; - - cerr << "Enter the number of elements: "; + if(prompt) + { + cerr << "Enter the number of elements: "; + } in >> number_count; data.numbers.resize(number_count); - - cerr << "\nEnter " << number_count << " elements:" << endl; - for (size_t i = 0; i < number_count; i++) { + if(prompt) + { + cerr << "\nEnter " << number_count << " elements:" << endl; + } + for (size_t i = 0; i < number_count; i++) + { in >> data.numbers[i]; } - - cerr << "Enter the number of bins: "; + if(prompt) + { + cerr << "Enter the number of bins: "; + } in >> data.bin_count; return data; @@ -30,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;