Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
61 строка
1.2 KiB
C++
61 строка
1.2 KiB
C++
#include <vector>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include "histogram.h"
|
|
#include "text.h"
|
|
#include "svg.h"
|
|
using namespace std;
|
|
struct Input {
|
|
vector<double> numbers;
|
|
size_t bin_count{};
|
|
string stroke;
|
|
};
|
|
|
|
Input
|
|
input_data() {
|
|
int i;
|
|
size_t number_count;
|
|
string check1 = " ";
|
|
string check2 = "#";
|
|
|
|
cerr << "Enter number count: ";
|
|
cin >> number_count;
|
|
|
|
Input in;
|
|
in.numbers.resize(number_count);
|
|
cerr << "Enter numbers: ";
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
cin >> in.numbers[i];
|
|
}
|
|
|
|
cerr << "Enter bin count: ";
|
|
cin >> in.bin_count;
|
|
|
|
|
|
cerr << "Enter stroke colour without spaces or in code format:";
|
|
cin.ignore();
|
|
getline(cin, in.stroke);
|
|
|
|
for (i = 0; i < in.stroke.length(); i++) {
|
|
if (isspace(in.stroke[i])) {
|
|
cerr << "invalid input";
|
|
}
|
|
}
|
|
if (in.stroke[0] == check2[0]) {
|
|
if (in.stroke.length() != 7) {
|
|
cerr << "invalid input";
|
|
}
|
|
}
|
|
return in;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
const size_t SCREEN_WIDTH = 80;
|
|
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
|
auto in = input_data();
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
show_histogram_svg(bins, in.stroke);
|
|
return 0;
|
|
}
|