code: добавлен параметр prompt для вывода подсказок

main
MatusSV 1 год назад
Родитель 191fd262a0
Сommit 0b72e913b2

@ -14,11 +14,11 @@ struct Input {
};
Input
input_data(istream& in_stream) {
input_data(istream& in_stream,bool prompt) {
size_t number_count;
Input in;
cerr << "Enter number count: ";
if (prompt) cerr << "Enter number count: ";
in_stream >> number_count;
vector<double> numbers(number_count);
@ -28,7 +28,7 @@ input_data(istream& in_stream) {
in_stream >> in.numbers[i];
}
cerr << "Enter bins count and colors: ";
if (prompt) cerr << "Enter bins count and colors: ";
in_stream >> in.bin_count;
vector<string> colors(in.bin_count);
in.colors.resize(in.bin_count);
@ -37,7 +37,7 @@ input_data(istream& in_stream) {
in_stream >> in.colors[i];
bool check = check_color(in.colors[i]);
while (!check) {
cerr << "Incorrect input. Color doesn't contain # or has spaces." << endl;
if (prompt) cerr << "Incorrect input. Color doesn't contain # or has spaces." << endl;
in_stream >> in.colors[i];
check = check_color(in.colors[i]);
}
@ -47,7 +47,7 @@ input_data(istream& in_stream) {
int main()
{
auto in = input_data(cin);
auto in = input_data(cin,true);
vector<size_t> bins = make_histogram(in.numbers, in.bin_count);
//show_histogram_text(bins, in.bin_count);
show_histogram_svg(bins, in.colors);

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