From 18ff2100f6e8d33d5d864edb0b4b25dbf974e7f4 Mon Sep 17 00:00:00 2001 From: AglowTexas3 <107749250+AglowTexas3@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:52:43 +0300 Subject: [PATCH] v2 --- lab01.depend | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lab01.layout | 28 +++++++++--------- main.cpp | 65 +++++++++++++++++++++++++++++++---------- text.cpp | 9 ++---- text.h | 2 +- 5 files changed, 148 insertions(+), 38 deletions(-) diff --git a/lab01.depend b/lab01.depend index 31f9f23..9644a59 100644 --- a/lab01.depend +++ b/lab01.depend @@ -85,3 +85,85 @@ 1694255976 c:\users\texas\desktop\lab01\curl\include\curl\typecheck-gcc.h +1696103005 source:c:\users\texas\desktop\Новая папка\cs-lab34\histogram.cpp + "histogram.h" + +1696103005 c:\users\texas\desktop\Новая папка\cs-lab34\histogram.h + + +1696103005 source:c:\users\texas\desktop\Новая папка\cs-lab34\svg.cpp + "svg.h" + + +1696103005 c:\users\texas\desktop\Новая папка\cs-lab34\svg.h + + + + +1696105472 source:c:\users\texas\desktop\Новая папка\cs-lab34\text.cpp + "text.h" + + +1696104652 c:\users\texas\desktop\Новая папка\cs-lab34\text.h + + + +1696106452 source:c:\users\texas\desktop\Новая папка\cs-lab34\main.cpp + + + + + + + "histogram.h" + "text.h" + "svg.h" + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\curl.h + "curlver.h" + "system.h" + + + + + + + + + + + "easy.h" + "multi.h" + "urlapi.h" + "options.h" + "header.h" + "websockets.h" + "typecheck-gcc.h" + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\curlver.h + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\system.h + + + + + + + + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\easy.h + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\multi.h + "curl.h" + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\urlapi.h + "curl.h" + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\options.h + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\header.h + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\websockets.h + +1694255976 c:\users\texas\desktop\Новая папка\cs-lab34\curl\include\curl\typecheck-gcc.h + diff --git a/lab01.layout b/lab01.layout index fb36717..1f2043d 100644 --- a/lab01.layout +++ b/lab01.layout @@ -2,39 +2,39 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/main.cpp b/main.cpp index 8544c76..a41e0c4 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,6 @@ using namespace std; struct Input { vector numbers; size_t bin_count{}; - float n; }; Input @@ -33,19 +32,10 @@ input_data(istream& in,bool prompt) { Input on; on.numbers.resize(number_count); for (size_t i = 0; i < number_count; i++) { - cerr << b << i+1 << ": "; + //cerr << b << i+1 << ": "; in >> on.numbers[i];} cerr << c; in >> on.bin_count; - - on.n = 0; - if (on.bin_count==0){ - on.bin_count = sqrt(number_count); - on.n = 1; - if (on.bin_count > 25){ - on.bin_count = 1 + log2(number_count); - on.n = 2;}} - return on; } @@ -80,12 +70,55 @@ 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";}} + else{ + if ((format=argv[2])== "-format"){ + if (argc ==3) + cerr << "wrong type"; + else + if ((type=argv[3])== "svg"){ + input = download(argv[1]); + const auto bins = make_histogram(input.numbers, input.bin_count); + show_histogram_svg(bins);} + + else if ((type=argv[3])== "text"){ + input = download(argv[1]); + + auto bins = make_histogram(input.numbers, input.bin_count); + show_histogram_text(bins, input.bin_count);} + + }} + } + + + + + //auto bins = make_histogram(in.numbers, in.bin_count); + //show_histogram_text(bins, in.bin_count, in.n); + + + /*if ((adr=argv[1]).substr(0,7)== "http://"){ + input = download(argv[1]); + if ((type=argv[2])== "svg"){ + const auto bins = make_histogram(input.numbers, input.bin_count); + show_histogram_svg(bins);}*/ + - const auto bins = make_histogram(input); - show_histogram_svg(bins); return 0; } diff --git a/text.cpp b/text.cpp index 3aa5fbf..99a849a 100644 --- a/text.cpp +++ b/text.cpp @@ -4,13 +4,7 @@ using namespace std; void -show_histogram_text(vector& bins, size_t bin_count, float n){ - if (n != 0){ - cout << "bin count = " << bin_count; - if (n == 1) - cout << " using 1st" << '\n'; - else - cout << " using 2nd" << '\n';} +show_histogram_text(vector& bins, size_t bin_count){ for (size_t i = 0; i < bin_count; i++) { if (bins[i]<100) cout << " "; @@ -20,4 +14,5 @@ show_histogram_text(vector& bins, size_t bin_count, float n){ for (size_t j = 0; j < bins[i]; j++){ cout << "*";} cout << '\n';} + return; } diff --git a/text.h b/text.h index 4371e7d..9c93fca 100644 --- a/text.h +++ b/text.h @@ -3,6 +3,6 @@ #include #include -void show_histogram_text(std::vector& bins, size_t bin_count, float n); +void show_histogram_text(std::vector& bins, size_t bin_count); #endif // TEXT_H_INCLUDED