diff --git a/main.cpp b/main.cpp index 5f70b72..5cd9e15 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "histogram.h" #include "text.h" #include "svg.h" @@ -11,22 +12,32 @@ struct Input { size_t bin_count{}; }; Input -input_data(istream& in){ +input_data(istream& in, bool prompt){ + cerr << "Do you need hints? Type 0 for no, 1 for yes: "; + int ans; + int state = 0; + while (state ==0){ + in >> ans; + if (ans==1) {prompt = true; state=1;} + else if (ans==0) {prompt = false; state=1;} + else cerr << "Invalid data. Please type only 0 or 1: "; + } size_t number_count; - cerr << "Enter number count: "; + if (prompt == true) cerr << "Enter number count: "; in >> number_count; Input input; input.numbers.resize(number_count); - cerr << "Enter numbers: "; + if (prompt == true) cerr << "Enter numbers: "; for (size_t i = 0; i < number_count; i++){ in >> input.numbers[i]; } - cerr << "Enter bin count: "; + if (prompt == true) cerr << "Enter bin count: "; in >> input.bin_count; return input; } int main(){ - auto in = input_data(cin); + bool prompt; + auto in = input_data(cin, prompt); auto bins = make_histogram(in.numbers, in.bin_count); show_histogram_svg(bins); }