#include #include #include #include #include "histogram.h" #include "svg.h" #include using namespace std; static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) { size_t real_size = size * nmemb; stringstream* buffer = static_cast(userp); buffer->write(static_cast(contents), real_size); return real_size; } int main(int argc, char* argv[]) { Input download(const std::string& url); curl_global_init(CURL_GLOBAL_ALL); Input input; if(argc > 1) { try { input = download(argv[1]); } catch(const exception& e) { cerr << "Ошибка загрузки: " << e.what() << endl; curl_global_cleanup(); return EXIT_FAILURE; } } else { input = input_data(cin, true); } auto bins = make_histogram(input.numbers, input.bin_count); show_histogram_text(bins); int dash_len, gap_len; cout << "Введите длину штриха (например, 20): "; cin >> dash_len; cout << "Введите длину промежутка (например, 10): "; cin >> gap_len; ofstream svg_file("histogram.svg"); if(svg_file) { svg::show_histogram_svg(svg_file, bins, dash_len, gap_len); cout << "Гистограмма сохранена в histogram.svg" << endl; } else { cerr << "Ошибка: не удалось создать файл SVG" << endl; } curl_global_cleanup(); return EXIT_SUCCESS; }