Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
51 строка
1.3 KiB
C++
51 строка
1.3 KiB
C++
#include <vector>
|
|
#include <math.h>
|
|
#include <iostream>
|
|
#include <conio.h>
|
|
#include <curl/curl.h>
|
|
#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, bool prompt){
|
|
cerr << "Do you need hints? Type 0 for no, 1 for yes: ";
|
|
int ans;
|
|
int state = 0;
|
|
while (state ==0){
|
|
in >> ans;
|
|
if (ans==1) {prompt = true; state=1;}
|
|
else if (ans==0) {prompt = false; state=1;}
|
|
else cerr << "Invalid data. Please type only 0 or 1: ";
|
|
}
|
|
size_t number_count;
|
|
if (prompt == true) cerr << "Enter number count: ";
|
|
in >> number_count;
|
|
Input input;
|
|
input.numbers.resize(number_count);
|
|
if (prompt == true) cerr << "Enter numbers: ";
|
|
for (size_t i = 0; i < number_count; i++){
|
|
in >> input.numbers[i];
|
|
}
|
|
if (prompt == true) cerr << "Enter bin count: ";
|
|
in >> input.bin_count;
|
|
return input;
|
|
}
|
|
int main(int argc, char* argv[]){
|
|
if (argc>1){
|
|
for (size_t i =0; i<argc; i++){
|
|
cerr << "argv[" << i << "]= " << argv[i] << "\n";
|
|
}
|
|
return 0;
|
|
}
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
bool prompt;
|
|
auto in = input_data(cin, prompt);
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
show_histogram_svg(bins);
|
|
}
|