Сравнить коммиты
Ничего общего в коммитах. '5086c43a27261ed7c3c73298e2c59d9c6d73186d' и '8c17279d7f02f7630ee6de7c9ba2774247f8d6ed' имеют совершенно разные истории.
5086c43a27
...
8c17279d7f
@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
struct Input {
|
struct Input {
|
||||||
std::vector<double> numbers;
|
std::vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Input input_data(std::istream& in, bool prompt);
|
Input input_data();
|
||||||
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
||||||
|
void show_histogram_text(const std::vector<size_t>& bins);
|
||||||
|
@ -1,55 +1,9 @@
|
|||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include <curl/curl.h>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
size_t write_data(void* ptr, size_t size, size_t nmemb, std::stringstream* stream) {
|
auto in = input_data();
|
||||||
size_t data_size = size * nmemb;
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
stream->write(static_cast<const char*>(ptr), data_size);
|
|
||||||
return data_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Input download(const std::string& url) {
|
|
||||||
std::stringstream buffer;
|
|
||||||
|
|
||||||
CURL* curl = curl_easy_init();
|
|
||||||
if (!curl) {
|
|
||||||
std::cerr << "Failed to initialize cURL\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
||||||
|
|
||||||
CURLcode res = curl_easy_perform(curl);
|
|
||||||
if (res != CURLE_OK) {
|
|
||||||
std::cerr << "cURL error: " << curl_easy_strerror(res) << "\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
return input_data(buffer, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
|
||||||
|
|
||||||
Input input;
|
|
||||||
if (argc > 1) {
|
|
||||||
std::cout << "Êîëè÷åñòâî àðãóìåíòîâ: " << argc << std::endl;
|
|
||||||
for (int i = 0; i < argc; ++i) {
|
|
||||||
std::cout << "argv[" << i << "] = " << argv[i] << std::endl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto bins = make_histogram(input.numbers, input.bin_count);
|
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
|
|
||||||
curl_global_cleanup();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче