code: в input_data добавлен новый параметр bool promt
Этот коммит содержится в:
@@ -12,21 +12,36 @@ struct Input {
|
|||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Input input_data(istream& in_stream) {
|
Input input_data(istream& in_stream, bool prompt) {
|
||||||
Input in;
|
Input in;
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
|
|
||||||
|
if (prompt) {
|
||||||
|
cerr << "Enter number count: ";
|
||||||
|
}
|
||||||
in_stream >> number_count;
|
in_stream >> number_count;
|
||||||
|
|
||||||
in.numbers.resize(number_count);
|
in.numbers.resize(number_count);
|
||||||
|
if (prompt) {
|
||||||
|
cerr << "Enter " << number_count << " numbers: ";
|
||||||
|
}
|
||||||
for (size_t i = 0; i < number_count; i++) {
|
for (size_t i = 0; i < number_count; i++) {
|
||||||
in_stream >> in.numbers[i];
|
in_stream >> in.numbers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prompt) {
|
||||||
|
cerr << "Enter bin count: ";
|
||||||
|
}
|
||||||
in_stream >> in.bin_count;
|
in_stream >> in.bin_count;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
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_svg(bins);
|
show_histogram_svg(bins);
|
||||||
show_histogram_text(bins);
|
show_histogram_text(bins);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user