code: ЛР4 параметр prompt

master
Alexander (AntonovichAN) 7 месяцев назад
Родитель 841f6d02cb
Сommit 91b6bea919

@ -13,20 +13,26 @@ struct Input {
size_t bin_count{}; size_t bin_count{};
}; };
Input input_data(istream& in) { Input input_data(istream& in, bool prompt) {
size_t number_count; size_t number_count;
cerr << "Enter number count: "; if (prompt){
cerr << "Enter number count: ";
}
in >> number_count; in >> number_count;
Input on; Input on;
cerr << "Enter bin count: "; if (prompt){
cerr << "Enter bin count: ";
}
in >> on.bin_count; in >> on.bin_count;
on.numbers.resize(number_count); on.numbers.resize(number_count);
cerr << "Enter numbers: "; if (prompt){
cerr << "Enter numbers: ";
}
for (size_t i = 0; i < number_count; i++) { for (size_t i = 0; i < number_count; i++) {
in >> on.numbers[i]; in >> on.numbers[i];
} }
@ -34,7 +40,8 @@ Input input_data(istream& in) {
}; };
int main(){ 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); auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_text(bins, in.bin_count); show_histogram_text(bins, in.bin_count);
show_histogram_svg(bins); show_histogram_svg(bins);

Загрузка…
Отмена
Сохранить