|
|
|
@ -4,6 +4,8 @@
|
|
|
|
|
#include "histogram.h"
|
|
|
|
|
#include "text.h"
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
@ -67,35 +69,48 @@ struct Input {
|
|
|
|
|
int NCharts = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input input_data() {
|
|
|
|
|
Input input_data(istream& instr, bool promt) {
|
|
|
|
|
Input in;
|
|
|
|
|
int VecSize = 0;
|
|
|
|
|
cin >> VecSize;
|
|
|
|
|
if (promt) { cout << "input num of marks\n"; }
|
|
|
|
|
instr >> VecSize;
|
|
|
|
|
in.marks.resize(VecSize);
|
|
|
|
|
if (promt) { cout << "input num marks\n"; }
|
|
|
|
|
for (int i = 0; i < VecSize; i++) {
|
|
|
|
|
cin >> in.marks[i];
|
|
|
|
|
instr >> in.marks[i];
|
|
|
|
|
}
|
|
|
|
|
cin >> in.NCharts;
|
|
|
|
|
if (promt) { cout << "input num of charts\n"; }
|
|
|
|
|
instr >> in.NCharts;
|
|
|
|
|
return in;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input download(const string& address) {
|
|
|
|
|
stringstream buffer;
|
|
|
|
|
|
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
|
if (curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
|
cout << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]){
|
|
|
|
|
Input input;
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
|
if (curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
|
cout << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
input = input_data(cin, true);
|
|
|
|
|
}
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
vector <double> chart = MakeHistogram(in.marks, in.NCharts);
|
|
|
|
|
vector <double> chart = MakeHistogram(input.marks, input.NCharts);
|
|
|
|
|
//show_histogram_text(in.marks, chart);
|
|
|
|
|
show_histogram_svg(in.marks, chart);
|
|
|
|
|
show_histogram_svg(input.marks, chart);
|
|
|
|
|
}
|