From a9f6cdfc205be4df961f697eecb1c63f8b988340 Mon Sep 17 00:00:00 2001 From: FilippovDY Date: Mon, 20 May 2024 19:13:34 +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=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 442eae3..8b26496 100644 --- a/main.cpp +++ b/main.cpp @@ -14,21 +14,23 @@ struct Input { }; Input -input_data(istream& stream) { +input_data(istream& stream, bool prompt) { size_t number_count; - cerr << "Enter number count: "; + if (prompt) { + cerr << "Enter number count: "; + } stream >> number_count; Input in; + if (prompt) { + cerr << "Enter bin count: "; + } + stream >> in.bin_count; vector numbers(in.number_count); in.numbers.resize(in.number_count); for (size_t i = 0; i < in.number_count; i++) { stream >> in.numbers[i]; } - size_t bin_count; - cerr << "Enter bin count: "; - stream >> in.bin_count; - size_t max_count; in.max_count = 0; return in; @@ -38,7 +40,8 @@ input_data(istream& stream) { 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, in.number_count, in.max_count); vector test; show_histogram_svg(bins, in.max_count, in.bin_count, test);