From dcfc406037fb0b1c666abf101eefd57afb174968 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 13 Oct 2024 17:26:19 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=9B=D0=A04=20=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B0=D0=BD=D1=82=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 2587843..a8af34a 100644 --- a/main.cpp +++ b/main.cpp @@ -73,14 +73,24 @@ Input download(const string& address) { int main( int argc, char* argv[]){ Input input; if (argc > 1){ - input = download(argv[1]); - }else{ - input = input_data(cin, true); + string adr, format, type; + if ((adr=argv[1]).substr(0,7)!= "http://"){ + if ((format=argv[1])== "-format"){ + if ((type=argv[2])== "svg"){ + input = download(argv[3]); + const auto bins = make_histogram(input.numbers, input.bin_count); + show_histogram_svg(bins); + }else if ((type=argv[2])== "text"){ + input = download(argv[3]); + auto bins = make_histogram(input.numbers, input.bin_count); + show_histogram_text(bins, input.bin_count); + }else{ + cerr << "wrong type, choose format 'svg' or 'txt'"; + } + }else{ + cerr << "type '-format' to choose output format"; + } + } } - - const auto bins = make_histogram(input); - - show_histogram_text(bins, in.bin_count); - show_histogram_svg(bins); }