code: add prompt
Этот коммит содержится в:
10
main.cpp
10
main.cpp
@@ -11,9 +11,11 @@ struct Input {
|
|||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Input input_data(istream& in1) {
|
Input input_data(istream& in1, bool prompt) {
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
|
if (prompt) {
|
||||||
cerr << "Enter number count: ";
|
cerr << "Enter number count: ";
|
||||||
|
}
|
||||||
in1 >> number_count;
|
in1 >> number_count;
|
||||||
|
|
||||||
Input in;
|
Input in;
|
||||||
@@ -24,8 +26,9 @@ Input input_data(istream& in1) {
|
|||||||
{
|
{
|
||||||
in1 >> in.numbers[i];
|
in1 >> in.numbers[i];
|
||||||
}
|
}
|
||||||
|
if (prompt) {
|
||||||
cerr << "Enter number bin: ";
|
cerr << "Enter number bin: ";
|
||||||
|
}
|
||||||
in1 >> in.bin_count;
|
in1 >> in.bin_count;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
@@ -35,7 +38,8 @@ Input input_data(istream& in1) {
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
auto in = input_data(cin);
|
bool prompt = false;
|
||||||
|
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);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user