Грудинин Егор 11 месяцев назад
Родитель bc13e8ad19
Сommit bfaabf968a

@ -1,5 +1,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <sstream>
#include <string>
#include <curl/curl.h> #include <curl/curl.h>
#include "histogram.h" #include "histogram.h"
#include "text.h" #include "text.h"
@ -35,13 +37,13 @@ Input input_data(istream& stream, bool prompt) {
return in; return in;
} }
int main(int argc, char* argv[]) Input
{ download(const string& address) {
if (argc > 1) { stringstream buffer;
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!=CURLE_OK){ if (res!=CURLE_OK){
cerr << curl_easy_strerror(res); cerr << curl_easy_strerror(res);
@ -49,9 +51,17 @@ int 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);
} }
Input in = input_data(cin, false); const auto bins = make_histogram(input.numbers, input.bin_count);
vector<size_t> bins = make_histogram(in.numbers, in.bin_count);
show_histogram_svg(bins); show_histogram_svg(bins);
} }

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