Сравнить коммиты
2 Коммитов
bb51ae70ea
...
ee9b12fc4f
Автор | SHA1 | Дата |
---|---|---|
|
ee9b12fc4f | 3 месяцев назад |
|
30304c0921 | 3 месяцев назад |
@ -1,28 +1,45 @@
|
|||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
struct Input {
|
struct Input {
|
||||||
vector<double> vec;
|
vector<double> vec;
|
||||||
size_t korz{};
|
size_t korz{};
|
||||||
};
|
};
|
||||||
Input input_data() {
|
|
||||||
Input in;
|
Input input_data(istream &in, bool prompt) {
|
||||||
|
Input data;
|
||||||
size_t n, korz;
|
size_t n, korz;
|
||||||
|
|
||||||
cerr << "Number of elements: ";
|
if (prompt) {
|
||||||
cin >> n;
|
cerr << "Number of elements: ";
|
||||||
in.vec.resize(n);
|
}
|
||||||
cerr << "Elements: ";
|
in >> n;
|
||||||
|
data.vec.resize(n);
|
||||||
|
|
||||||
|
if (prompt) {
|
||||||
|
cerr << "Elements: ";
|
||||||
|
}
|
||||||
for (size_t i = 0; i < n; i++)
|
for (size_t i = 0; i < n; i++)
|
||||||
cin >> in.vec[i];
|
in >> data.vec[i];
|
||||||
cerr << "Enter bin count: ";
|
|
||||||
cin >> in.korz;
|
if (prompt) {
|
||||||
return in;
|
cerr << "Enter bin count: ";
|
||||||
|
}
|
||||||
|
in >> korz;
|
||||||
|
data.korz = korz;
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
auto in = input_data();
|
|
||||||
auto bins = make_histogram(in.korz, in.vec);
|
auto in_with_prompt = input_data(cin, true);
|
||||||
show_histogram_svg(bins);
|
auto bins_with_prompt = make_histogram(in_with_prompt.korz, in_with_prompt.vec);
|
||||||
|
show_histogram_svg(bins_with_prompt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче