From dcfdc59a63b62ac1118d33c8bab5ac7fdd1baf1f Mon Sep 17 00:00:00 2001 From: "Dima (AntonovDA)" Date: Mon, 6 May 2024 22:59:00 +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=BE=D1=82=D0=BE=D0=BA=20=D0=B2=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- l03.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/l03.cpp b/l03.cpp index 7569933..dbc0ea0 100644 --- a/l03.cpp +++ b/l03.cpp @@ -15,56 +15,57 @@ struct Input vector numbers; size_t bin_count{}; size_t IMAGE_WIDTH{}; - bool valid; }; -Input input_data() +Input +input_data(istream& in) { size_t number_count, bin_count, IMAGE_WIDTH; cerr << "Enter number count: "; - cin >> number_count; + in >> number_count; - Input in; + Input n; cerr << " Input width of image, > 70 but not >800 : "; - cin >> in.IMAGE_WIDTH; - if(in.IMAGE_WIDTH < 70 || in.IMAGE_WIDTH > 800 ) { - while(in.IMAGE_WIDTH < 70 || in.IMAGE_WIDTH > 800) { + in >> n.IMAGE_WIDTH; + if(n.IMAGE_WIDTH < 70 || n.IMAGE_WIDTH > 800 ) { + while(n.IMAGE_WIDTH < 70 || n.IMAGE_WIDTH > 800) { cerr << " Input width of image, >70 but not >800 : "; - cin >> in.IMAGE_WIDTH; + in >> n.IMAGE_WIDTH; } } + //size_t number_count = in.number_counts; - in.numbers.resize( number_count ); + n.numbers.resize( number_count ); cerr << "Enter numbers: "; // vector numbers(number_count); for (size_t i = 0; i < number_count; i++) { - cin >> in.numbers[i]; + in >> n.numbers[i]; } cerr << "Count of baskets: "; - cin >> in.bin_count; + in >> n.bin_count; - return in; + return n; } int main() { - auto in = input_data(); - auto bins = make_histogram( in.numbers, in.bin_count ); + auto n = input_data(cin); + auto bins = make_histogram( n.numbers, n.bin_count ); //int chek_block_width(in.IMAGE_WIDTH); //chek_block_width(in.IMAGE_WIDTH, in.number_count); - //if (chek_block_width==1) - show_histogram_svg( bins,in.IMAGE_WIDTH ); + //if (chek_block_width==1) + show_histogram_svg( bins,n.IMAGE_WIDTH ); //if(chek_block_width==0) return 0; //show_histogram_svg(bins);