|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
#include "histogram.h"
|
|
|
|
|
#include "text.h"
|
|
|
|
|
#include "svg.h"
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
struct Input
|
|
|
|
@ -38,18 +39,44 @@ input_data(istream& inn)
|
|
|
|
|
inn >> in.bin_count;
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
size_t write_data(void* ptr, size_t size, size_t nmemb, void* stream)
|
|
|
|
|
{
|
|
|
|
|
size_t written = fwrite(ptr, size, nmemb, stdout);
|
|
|
|
|
return written;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
auto in = input_data(cin);
|
|
|
|
|
if (argc > 1)
|
|
|
|
|
{
|
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
|
if (curl)
|
|
|
|
|
{
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
|
|
if (res != CURLE_OK)
|
|
|
|
|
{
|
|
|
|
|
cerr << "cURL error: " << curl_easy_strerror(res) << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double min, max;
|
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
|
|
|
show_histogram_text(bins, in.bin_count, bin_size);
|
|
|
|
|
//show_histogram_svg(bins);
|
|
|
|
|
//# Ïåðåìåííûå + íà÷àëî ïðîãðàììû(ââîäû)
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "curl_easy_init() failed" << endl;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
auto in = input_data(cin);
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
//show_histogram_text(bins, in.bin_count, bin_size);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
// | 3 3 5 5 5 4 4 4 4 4
|
|
|
|
|
|
|
|
|
|