Сравнить коммиты
5 Коммитов
6d92425a8c
...
112373a5bd
Автор | SHA1 | Дата |
---|---|---|
![]() |
112373a5bd | 2 лет назад |
![]() |
3818146131 | 2 лет назад |
![]() |
d25177cf18 | 2 лет назад |
![]() |
468675743d | 2 лет назад |
![]() |
cd14de2329 | 2 лет назад |
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_layout_file>
|
||||||
|
<FileVersion major="1" minor="0" />
|
||||||
|
<ActiveTarget name="Debug" />
|
||||||
|
<File name=".gitignore" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="29" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="3" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1800" topLine="59" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
</CodeBlocks_layout_file>
|
@ -1,39 +1,120 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "vector"
|
#include <vector>
|
||||||
#include "svg.h"
|
#include <conio.h>
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
//#include "curl/curl.h"
|
#include "text.h"
|
||||||
|
#include "svg.h"
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
struct Input
|
||||||
|
{
|
||||||
|
|
||||||
struct Input {
|
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Input
|
Input
|
||||||
input_data(istream& inn, bool promt) {
|
input_data(istream& in, bool promt)
|
||||||
|
{
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
cin >> number_count;
|
if (promt)
|
||||||
Input in;
|
{
|
||||||
in.numbers.resize(number_count);
|
cerr << "Enter number count: ";
|
||||||
|
}
|
||||||
|
in >> number_count;
|
||||||
|
|
||||||
|
Input ik;
|
||||||
|
ik.numbers.resize(number_count);
|
||||||
|
for (size_t i = 0; i < number_count; i++)
|
||||||
|
{
|
||||||
|
in >> ik.numbers[i];
|
||||||
|
}
|
||||||
|
if (promt)
|
||||||
|
{
|
||||||
|
cerr << "Enter bin count: ";
|
||||||
|
}
|
||||||
|
in>> ik.bin_count;
|
||||||
|
return ik;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx)
|
||||||
|
{
|
||||||
|
size_t data_size = item_size * item_count;
|
||||||
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
||||||
|
buffer->write(reinterpret_cast<const char*>(items), data_size);
|
||||||
|
return data_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Input
|
||||||
|
download(const string& address)
|
||||||
|
{
|
||||||
|
stringstream buffer;
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
if(curl)
|
||||||
|
{
|
||||||
|
CURLcode res;
|
||||||
|
double file_size;
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
for (size_t i = 0; i < number_count; i++) {
|
|
||||||
cin >> in.numbers[i];
|
|
||||||
}
|
}
|
||||||
|
return input_data(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
cin >> in.bin_count;
|
|
||||||
return in;
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
Input input;
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
input = download(argv[3]);
|
||||||
|
int bins_cnt = atoi(argv[2]);
|
||||||
|
string check = typeid(atoi(argv[2])).name();
|
||||||
|
if(check != "int"){
|
||||||
|
cout << "Ââåäèòå ÷èñëî ïîñëå -bins";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const auto bins = make_histogram(input.numbers, bins_cnt);
|
||||||
|
show_histogram_svg(bins);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
input = input_data(cin, true);
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
|
show_histogram_svg(bins);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
Input input;
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
int bins_cnt = atoi(argv[2]);
|
||||||
|
input = download(argv[3]);
|
||||||
|
const auto bins = make_histogram(input.numbers, bins_cnt);
|
||||||
|
|
||||||
int main() {
|
}
|
||||||
// curl_global_init(CURL_GLOBAL_ALL);
|
else
|
||||||
auto in = input_data(cin, true);
|
{
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
input = input_data(cin, true);
|
||||||
show_histogram_text(bins, in.bin_count);
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
//show_histogram_svg(bins);
|
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Загрузка…
Ссылка в новой задаче