code: добавлен параметр prompt
Этот коммит содержится в:
8
main.cpp
8
main.cpp
@@ -12,10 +12,12 @@ struct Input
|
|||||||
};
|
};
|
||||||
|
|
||||||
Input
|
Input
|
||||||
input_data(istream& stream)
|
input_data(istream& stream, bool prompt)
|
||||||
{
|
{
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
|
if (prompt) {
|
||||||
cerr << "Enter number count: ";
|
cerr << "Enter number count: ";
|
||||||
|
}
|
||||||
stream >> number_count;
|
stream >> number_count;
|
||||||
Input in;
|
Input in;
|
||||||
in.numbers.resize(number_count);
|
in.numbers.resize(number_count);
|
||||||
@@ -23,14 +25,16 @@ input_data(istream& stream)
|
|||||||
{
|
{
|
||||||
stream >> in.numbers[i];
|
stream >> in.numbers[i];
|
||||||
}
|
}
|
||||||
|
if (prompt) {
|
||||||
cerr << "Enter bin count: ";
|
cerr << "Enter bin count: ";
|
||||||
|
}
|
||||||
stream >> in.bin_count;
|
stream >> in.bin_count;
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Input in = input_data(cin);
|
Input in = input_data(cin, true);
|
||||||
vector<size_t> bins = make_histogram(in.numbers, in.bin_count);
|
vector<size_t> bins = make_histogram(in.numbers, in.bin_count);
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user