From 91b6bea91986e683f39811840b4e8ffb78818b4f Mon Sep 17 00:00:00 2001 From: "Alexander (AntonovichAN)" Date: Sun, 6 Oct 2024 16:32:32 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=9B=D0=A04=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index f14eca6..2bd6be5 100644 --- a/main.cpp +++ b/main.cpp @@ -13,20 +13,26 @@ struct Input { size_t bin_count{}; }; -Input input_data(istream& in) { +Input input_data(istream& in, bool prompt) { size_t number_count; - cerr << "Enter number count: "; + if (prompt){ + cerr << "Enter number count: "; + } in >> number_count; Input on; - cerr << "Enter bin count: "; + if (prompt){ + cerr << "Enter bin count: "; + } in >> on.bin_count; on.numbers.resize(number_count); - cerr << "Enter numbers: "; + if (prompt){ + cerr << "Enter numbers: "; + } for (size_t i = 0; i < number_count; i++) { in >> on.numbers[i]; } @@ -34,7 +40,8 @@ Input input_data(istream& in) { }; int main(){ - 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_text(bins, in.bin_count); show_histogram_svg(bins);