Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

54 строки
974 B
C++

#include <math.h>
#include <vector>
#include <iostream>
#include <string.h>
#include "histogram.h"
#include "text.h"
#include "svg.h"
using namespace std;
struct Input {
vector<double> numbers;
size_t bin_count{};
float n;
};
Input
input_data(istream& in) {
size_t number_count;
cerr << "Enter number count: ";
in >> number_count;
Input on;
on.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) {
cerr << "Enter number " << i+1 << ": ";
in >> on.numbers[i];}
cerr << "Enter bin count: ";
in >> on.bin_count;
on.n = 0;
if (on.bin_count==0){
on.bin_count = sqrt(number_count);
on.n = 1;
if (on.bin_count > 25){
on.bin_count = 1 + log2(number_count);
on.n = 2;}}
return on;
}
int main()
{
auto in = input_data(cin);
auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_svg(bins);
return 0;
}