|
|
|
@ -14,31 +14,26 @@ struct Input {
|
|
|
|
|
|
|
|
|
|
// Ââîä äàííûõ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Input input_data(istream& in) { // Óáðàí ïàðàìåòð prompt
|
|
|
|
|
Input data;
|
|
|
|
|
Input input_data(istream& in, bool prompt = false) {
|
|
|
|
|
Input in_data;
|
|
|
|
|
size_t number_count;
|
|
|
|
|
|
|
|
|
|
cerr << "Enter the number of elements: ";
|
|
|
|
|
if (prompt) cerr << "Enter number count: ";
|
|
|
|
|
in >> number_count;
|
|
|
|
|
|
|
|
|
|
data.numbers.resize(number_count);
|
|
|
|
|
|
|
|
|
|
cerr << "\nEnter " << number_count << " elements:" << endl;
|
|
|
|
|
in_data.numbers.resize(number_count);
|
|
|
|
|
if (prompt && number_count > 0) cerr << "Enter numbers: ";
|
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
|
in >> data.numbers[i];
|
|
|
|
|
in >> in_data.numbers[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cerr << "Enter the number of bins: ";
|
|
|
|
|
in >> data.bin_count;
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
if (prompt) cerr << "Enter bin count: ";
|
|
|
|
|
in >> in_data.bin_count;
|
|
|
|
|
return in_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
Input data = input_data(cin); // Òåïåðü âûçûâàåòñÿ áåç ïàðàìåòðà prompt
|
|
|
|
|
// ×èòàåì äàííûå ñ êîíñîëè ñ âûâîäîì ïîäñêàçîê
|
|
|
|
|
Input in_data = input_data(cin, true); // true - ïîäñêàçêè âûâîäÿòñÿ
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(data.numbers, data.bin_count);
|
|
|
|
|
auto bins = make_histogram(in_data.numbers, in_data.bin_count);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|