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

56 строки
1.2 KiB
C++

#include <iostream>
#include <vector>
#include "histogram.h1.h"
#include "svg.h"
#include <curl/curl.h>
using namespace std;
struct Input{
vector<double> numbers;
size_t bin_count{};
};
Input input_data(istream& in, bool prompt=false) {
size_t number_count;
if (prompt){
cerr << "Enter number count: ";
}
in >> number_count;
Input result; // Îáúÿâëÿåì ïåðåìåííóþ òèïà Input, êîòîðóþ áóäåì âîçâðàùàòü
result.numbers.resize(number_count);
for (size_t i = 0; i < number_count; ++i) {
in >> result.numbers[i];
}
if (prompt){
cerr << "Enter bin count: ";
}
in >> result.bin_count;
return result; // Âîçâðàùàåì çàïîëíåííóþ ñòðóêòóðó Input
}
int main(int argc, char* argv[]){
if (argc > 1){
cout << "argc= " << argc << endl;
for (int i = 0; i < argc; i++){
cout << "argv[" << i << "] = " << argv[i] << endl;
}
return 0;
}
if (curl_global_init(CURL_GLOBAL_ALL)!=0){
cerr << "failed cURL" << endl;
return 1;
};
auto in = input_data(cin);
auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_svg(bins);
curl_global_cleanup();
}