From 0b72e913b29a2adc83b647a076875813137c1135 Mon Sep 17 00:00:00 2001 From: MatusSV Date: Mon, 27 May 2024 08:02:27 +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=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=20prompt=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index c0121b0..faa8412 100644 --- a/main.cpp +++ b/main.cpp @@ -14,11 +14,11 @@ struct Input { }; Input -input_data(istream& in_stream) { +input_data(istream& in_stream,bool prompt) { size_t number_count; Input in; - cerr << "Enter number count: "; + if (prompt) cerr << "Enter number count: "; in_stream >> number_count; vector numbers(number_count); @@ -28,7 +28,7 @@ input_data(istream& in_stream) { in_stream >> in.numbers[i]; } - cerr << "Enter bins count and colors: "; + if (prompt) cerr << "Enter bins count and colors: "; in_stream >> in.bin_count; vector colors(in.bin_count); in.colors.resize(in.bin_count); @@ -37,7 +37,7 @@ input_data(istream& in_stream) { in_stream >> in.colors[i]; bool check = check_color(in.colors[i]); while (!check) { - cerr << "Incorrect input. Color doesn't contain # or has spaces." << endl; + if (prompt) cerr << "Incorrect input. Color doesn't contain # or has spaces." << endl; in_stream >> in.colors[i]; check = check_color(in.colors[i]); } @@ -47,7 +47,7 @@ input_data(istream& in_stream) { int main() { - auto in = input_data(cin); + auto in = input_data(cin,true); vector bins = make_histogram(in.numbers, in.bin_count); //show_histogram_text(bins, in.bin_count); show_histogram_svg(bins, in.colors);