diff --git a/Laba N 1.cbp b/Laba N 1.cbp
index e49e6af..2364d2f 100644
--- a/Laba N 1.cbp
+++ b/Laba N 1.cbp
@@ -31,11 +31,10 @@
-
-
+
diff --git a/main.cpp b/main.cpp
index 07842d0..180758f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,6 @@
#include
+#include
+#include
#include
#include
#include "text.h"
@@ -47,25 +49,43 @@ input_data(istream& inn,bool prompt) {
return in;
}
}
-int main(int argc, char* argv[])
-{
- if(argc>1)
- {
+size_t
+write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
+ size_t data_size = item_size * item_count;
+ stringstream* buffer = reinterpret_cast(ctx);
+ buffer->write(reinterpret_cast(items), data_size);
+ return data_size;
+}
+Input
+download(const string& address) {
+ stringstream buffer;
CURL* curl = curl_easy_init();
if(curl) {
CURLcode res;
- curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+ curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res!=0){
cout<1)
+ {
+ in = download(argv[1]);
+ }else {
+ in = input_data(cin, true);
}
curl_global_init(CURL_GLOBAL_ALL);
- auto in = input_data(cin,true);
+ //auto in = input_data(cin,true);
auto bins = make_histogram(in.numbers, in.bin_count);
auto max_count=bins[0];
@@ -75,7 +95,7 @@ int main(int argc, char* argv[])
max_count=x;
}
}
- show_histogram_text(bins,in.bin_count,in.numbers,max_count);
- //show_histogram_svg(bins, max_count);
+ //show_histogram_text(bins,in.bin_count,in.numbers,max_count);
+ show_histogram_svg(bins, max_count);
return 0;
}