Andrey 2 лет назад
Родитель 36ca33b6d7
Сommit 511108c2db

@ -1,3 +1,5 @@
#include <sstream>
#include <string>
#include <curl/curl.h> #include <curl/curl.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@ -35,16 +37,15 @@ input_data(istream& in, bool prompt)
return rez; return rez;
} }
int Input
main(int argc, char* argv[]) download(const string& address) {
{ stringstream buffer;
if (argc > 1)
{
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
if(curl) if(curl)
{ {
CURLcode res; CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]); curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != 0) if (res != 0)
{ {
@ -53,13 +54,23 @@ main(int argc, char* argv[])
} }
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
return 0; return input_data(buffer, false);
}
int
main(int argc, char* argv[])
{
Input input;
if (argc > 1) {
input = download(argv[1]);
} else {
input = input_data(cin, true);
} }
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
bool prompt = false; bool prompt = false;
auto in = input_data(cin, prompt); auto in = input_data(cin, prompt);
auto bins = make_histogram(in.numbers, in.bin_count); const auto bins = make_histogram(in.numbers, in.bin_count);
//show_histogram_svg(bins); show_histogram_svg(bins);
show_histogram_text(bins, in.numbers, in.bin_count); //show_histogram_text(bins, in.numbers, in.bin_count);
} }

Загрузка…
Отмена
Сохранить