Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
70 строки
1.4 KiB
C++
70 строки
1.4 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include "histogram.h"
|
|
#include "text.h"
|
|
#include "svg.h"
|
|
#include <cctype>
|
|
#include <limits>
|
|
|
|
|
|
|
|
using namespace std;
|
|
struct Input
|
|
{
|
|
vector<double> numbers;
|
|
size_t bin_count{};
|
|
};
|
|
|
|
Input
|
|
input_data()
|
|
{
|
|
Input in;
|
|
size_t number_count;
|
|
cerr << "Enter number count: ";
|
|
cin >> number_count;
|
|
|
|
in.numbers.resize(number_count);
|
|
vector<double> numbers(number_count);
|
|
|
|
for (size_t i = 0; i < number_count; i++)
|
|
{
|
|
cerr << "Enter numbers: ";
|
|
cin >> in.numbers[i];
|
|
}
|
|
size_t bin_count;
|
|
cerr << "Enter bin count: ";
|
|
cin >> in.bin_count;
|
|
return in;
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
Input in = input_data();
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
double min, max;
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
string decoration;
|
|
vector<string> valid_decorations = {"none", "underline", "overline", "line-through"};
|
|
|
|
while (true) {
|
|
cerr << "Enter text decoration (none/underline/overline/line-through): ";
|
|
cin >> decoration;
|
|
|
|
if (find(valid_decorations.begin(), valid_decorations.end(), decoration)
|
|
!= valid_decorations.end()) {
|
|
break;
|
|
}
|
|
|
|
cerr << "Please choose from: none, underline, overline, line-through" << "\n";
|
|
}
|
|
|
|
show_histogram_svg(bins, decoration);
|
|
|
|
// show_histogram_text(bins, in.bin_count, bin_size);
|
|
}
|
|
|