|
|
|
@ -7,6 +7,8 @@
|
|
|
|
|
#include "text.h"
|
|
|
|
|
#include "svg.h"
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
@ -50,36 +52,36 @@ Input input_data(istream& in, bool prompt)
|
|
|
|
|
return stct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
Input
|
|
|
|
|
download(const string& address)
|
|
|
|
|
{
|
|
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
stringstream buffer;
|
|
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
|
if(curl)
|
|
|
|
|
{
|
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
|
if(curl)
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
if (res != CURLE_OK)
|
|
|
|
|
{
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
if (res != CURLE_OK){
|
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ââîä ìàññèâà è êîëè÷åñòâà êîðçèí
|
|
|
|
|
auto in = input_data(cin, true);
|
|
|
|
|
|
|
|
|
|
//Ñîçäàíèå âåêòîðà bins äëÿ ãèñòîãðàììû
|
|
|
|
|
vector<size_t> bins = make_histogram(in.Numbers, in.bin_count);
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char* argv[]) {
|
|
|
|
|
Input input;
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
} else {
|
|
|
|
|
input = input_data(cin, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Âûâîä ãèñòîãðàììû
|
|
|
|
|
const auto bins = make_histogram(input.Numbers, input.bin_count);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
//show_histogram_text(bins);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|