46 строки
888 B
C++
46 строки
888 B
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{};
|
|
};
|
|
|
|
Input
|
|
input_data(istream& in) {
|
|
size_t number_count;
|
|
cerr << "Enter number count: ";
|
|
in >> number_count;
|
|
|
|
Input data;
|
|
data.numbers.resize(number_count);
|
|
|
|
vector<double> numbers(number_count);
|
|
for (int i = 0; i < number_count; i++)
|
|
{
|
|
cerr << "Number[" << i << "]=";
|
|
in >> data.numbers[i];
|
|
}
|
|
|
|
cerr << "Enter bin count: ";
|
|
in >> data.bin_count;
|
|
return data;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
auto in = input_data(cin);
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
/*double min, max;
|
|
double bin_size = (max - min) / in.bin_count;
|
|
show_histogram_text(bins,in.bin_count, bin_size);*/
|
|
show_histogram_svg(bins);
|
|
return 0;
|
|
}
|