Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
51 строка
1.1 KiB
C++
51 строка
1.1 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include "histogram.h"
|
|
#include "text.h"
|
|
#include "svg.h"
|
|
|
|
using namespace std;
|
|
|
|
|
|
struct Input {
|
|
vector<double> numbers;
|
|
size_t bin_count{};
|
|
size_t user_block_width;
|
|
};
|
|
|
|
Input
|
|
input_data() {
|
|
size_t number_count;
|
|
cerr << "Enter number count: ";
|
|
cin >> number_count;
|
|
Input in;
|
|
in.numbers.resize(number_count);
|
|
cerr << "Enter numbers: " << endl;
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
cin >> in.numbers[i];
|
|
}
|
|
cerr << "Enter bin count: ";
|
|
cin >> in.bin_count;
|
|
in.user_block_width = 15;
|
|
do {
|
|
cerr << "Enter block width: ";
|
|
cin >> in.user_block_width;
|
|
if ((in.user_block_width < 3) || (in.user_block_width > 30)){
|
|
cerr << "Error: block width must be included in the interval: [3; 30]" << endl;
|
|
}
|
|
}
|
|
while ((in.user_block_width < 3) || (in.user_block_width > 30));
|
|
|
|
return in;
|
|
}
|
|
|
|
|
|
int
|
|
main()
|
|
{
|
|
auto in = input_data();
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
show_histogram_svg(bins, in.user_block_width);
|
|
return 0;
|
|
}
|