Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
84 строки
1.3 KiB
C++
84 строки
1.3 KiB
C++
#include <vector>
|
|
#include <iostream>
|
|
#include<cmath>
|
|
#include "histogram.h"
|
|
#include "svg.h"
|
|
#include "text.h"
|
|
|
|
using namespace std;
|
|
|
|
struct Input {
|
|
vector<double> numbers;
|
|
size_t bin_count{};
|
|
size_t SCREEN_WIDTH{};
|
|
size_t number_count{};
|
|
|
|
};
|
|
|
|
Input
|
|
input_data() {
|
|
|
|
|
|
Input in;
|
|
cerr << "Enter number count: ";
|
|
cin >> in.number_count;
|
|
in.numbers.resize(in.number_count);
|
|
for (size_t i = 0; i < in.number_count; i++) {
|
|
cin >> in.numbers[i];
|
|
}
|
|
cerr<<"Enter bin count:";
|
|
cin >> in.bin_count;
|
|
|
|
|
|
|
|
while (true) {
|
|
//cerr << "Screen width: ";
|
|
//cin >> in.SCREEN_WIDTH;
|
|
in.SCREEN_WIDTH=80;
|
|
if (in.SCREEN_WIDTH < 7) {
|
|
cerr << "<7"; cerr << endl;
|
|
continue;
|
|
}
|
|
if (in.SCREEN_WIDTH > 80) {
|
|
cerr << ">80"; cerr << endl;
|
|
continue;
|
|
}
|
|
|
|
if (in.SCREEN_WIDTH < (in.number_count / 3)){
|
|
cerr << "<number_count/3"; cerr << endl;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
return in;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
auto in = input_data();
|
|
|
|
double min, max;
|
|
|
|
|
|
|
|
|
|
const size_t MAX_ASTERISK = in.SCREEN_WIDTH - 3 - 1;
|
|
|
|
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
|
|
|
|
|
//show_histogram_text(bins, MAX_ASTERISK, in.bin_count);
|
|
show_histogram_svg(bins);
|
|
|
|
}
|