code: datastream
Этот коммит содержится в:
30
labor01.cpp
30
labor01.cpp
@@ -5,6 +5,8 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
struct Input {
|
struct Input {
|
||||||
@@ -40,14 +42,13 @@ input_data(istream& inn, bool promt) {
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Input
|
||||||
|
download(const string& address) {
|
||||||
int main(int argc, char* argv[1]) {
|
stringstream buffer;
|
||||||
if (argc > 1) {
|
|
||||||
CURL* curl = curl_easy_init();
|
CURL* curl = curl_easy_init();
|
||||||
if (curl) {
|
if (curl) {
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
if (res != CURLE_OK) {
|
if (res != CURLE_OK) {
|
||||||
cerr << curl_easy_strerror(res);
|
cerr << curl_easy_strerror(res);
|
||||||
@@ -55,11 +56,18 @@ int main(int argc, char* argv[1]) {
|
|||||||
}
|
}
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
return 0;
|
return input_data(buffer, false);
|
||||||
}
|
}
|
||||||
bool promt = true;
|
|
||||||
auto in = input_data(cin, promt);
|
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
int main(int argc, char* argv[]) {
|
||||||
show_histogram_svg(bins, in.colors);
|
Input input;
|
||||||
return 0;
|
if (argc > 1) {
|
||||||
|
input = download(argv[1]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input = input_data(cin, true);
|
||||||
|
}
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_svg(bins);
|
||||||
}
|
}
|
||||||
Ссылка в новой задаче
Block a user