//main.cpp -- the program gets number count, numbers and bin size, then builds a histogram. //Task 15 -- make a scale under the histogram. #include #include #include #include "histogram.h" #include "text.h" #include "svg.h" using namespace std; struct Input { //data input vector numbers; size_t bin_count{}; size_t interval_task{}; }; Input input_data(istream& in, bool prompt) { //input data structure if (prompt == false) { //prompt output cerr.rdbuf(NULL); } size_t number_count; cerr << "Enter number count: \n"; cerr.flush(); in >> number_count; Input in_data_struct; in_data_struct.numbers.resize(number_count); for (size_t i = 0; i < number_count; i++) { cerr << "Enter number "<< i << " : \n"; in >> in_data_struct.numbers[i]; } cerr << "Enter bin count: \n"; in >> in_data_struct.bin_count; cerr << "Enter interval from task: \n"; in >> in_data_struct.interval_task; if ((in_data_struct.interval_task >= 2.0) && (in_data_struct.interval_task <= 9.0)) { //scale interval size check return in_data_struct; } else { std::cout << "ERROR"; //error situation and program exit exit(1); } } int main(int argc, char* argv[]) { if (argc > 1) { CURL* curl = curl_easy_init(); if (curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, argv[1]); res = curl_easy_perform(curl); if (CURLE_OK == 0) { cerr << curl_easy_strerror(res); exit(1); } curl_easy_cleanup(curl); } return 0; } curl_global_init(CURL_GLOBAL_ALL); auto in = input_data(cin, true); //input data auto bins = make_histogram(in.numbers, in.bin_count); //calculating bin size for the histogram show_histogram_svg(bins, in.interval_task); //histogram output in the format svg code return 0; }