diff --git a/main.cpp b/main.cpp index caf385e..cf0e423 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -57,28 +59,37 @@ input_data(istream& in, bool prompt) { } - -int main(int argc, char* argv[]) -{ - if (argc>1){ +Input +download(const string& address) { + stringstream buffer; CURL *curl = curl_easy_init(); if(curl) { CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, argv[0]); + curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res!=0){ cout< 1) { + input = download(argv[1]); + } else { + input = input_data(cin, true); + } + auto in = input_data(cin, true); - auto bins = make_histogram(in.numbers, in.bin_count, in.number_count, in.max_count); + const auto bins = make_histogram(in.numbers, in.bin_count, in.number_count, in.max_count); vector test; show_histogram_svg(bins, in.max_count, in.bin_count, test);