code: изменение main
Этот коммит содержится в:
25
main.cpp
25
main.cpp
@@ -2,7 +2,7 @@
|
||||
#include <iostream>
|
||||
#include "histogram.h"
|
||||
#include "text.h"
|
||||
#include "svg.h"
|
||||
#include "svg.h"
|
||||
using namespace std;
|
||||
|
||||
struct Input {
|
||||
@@ -10,29 +10,36 @@ struct Input {
|
||||
size_t bin_count{};
|
||||
};
|
||||
|
||||
Input input_data() {
|
||||
Input input_data(istream& in_stream, bool prompt) {
|
||||
Input in;
|
||||
size_t number_count;
|
||||
|
||||
cerr << "Enter number count: ";
|
||||
cin >> number_count;
|
||||
if (prompt) {
|
||||
cerr << "Enter number count: ";
|
||||
}
|
||||
in_stream >> number_count;
|
||||
|
||||
in.numbers.resize(number_count);
|
||||
cerr << "Enter numbers: ";
|
||||
if (prompt && number_count > 0) {
|
||||
cerr << "Enter numbers: ";
|
||||
}
|
||||
for (size_t i = 0; i < number_count; i++) {
|
||||
cin >> in.numbers[i];
|
||||
in_stream >> in.numbers[i];
|
||||
}
|
||||
|
||||
cerr << "Enter bin count: ";
|
||||
cin >> in.bin_count;
|
||||
if (prompt) {
|
||||
cerr << "Enter bin count: ";
|
||||
}
|
||||
in_stream >> in.bin_count;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto in = input_data();
|
||||
auto in = input_data(cin, true); // true - выводить подсказки
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user