From 68f82d1a3b8457a0d4afcf3342bd63786af0c816 Mon Sep 17 00:00:00 2001 From: ZelenkinaKM Date: Sun, 19 May 2024 14:59:49 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B1=D1=83=D1=84=D0=B5=D1=80=D0=BE=D0=BC,=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=BD=D1=8B=D0=BC=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=81=D0=B5=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) 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);