вся 4
Этот коммит содержится в:
65
main.cpp
65
main.cpp
@@ -15,37 +15,36 @@ using namespace std;
|
||||
|
||||
struct Input
|
||||
{
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
};
|
||||
|
||||
Input
|
||||
input_data(istream &sin, bool promt)
|
||||
{
|
||||
Input in;
|
||||
size_t number_count;
|
||||
Input in;
|
||||
size_t number_count;
|
||||
|
||||
if (promt)
|
||||
{
|
||||
cerr << "enter number count";
|
||||
}
|
||||
sin>> number_count;
|
||||
if (promt)
|
||||
{
|
||||
cerr << "enter number count";
|
||||
}
|
||||
sin>> number_count;
|
||||
|
||||
|
||||
in.numbers.resize(number_count);
|
||||
for (size_t i = 0; i < number_count; i++)
|
||||
{
|
||||
sin>> in.numbers[i];
|
||||
}
|
||||
|
||||
in.numbers.resize(number_count);
|
||||
for (size_t i = 0; i < number_count; i++)
|
||||
{
|
||||
sin>> in.numbers[i];
|
||||
}
|
||||
if (promt)
|
||||
{
|
||||
cerr<<"enter bin count:";
|
||||
}
|
||||
sin >>in.bin_count;
|
||||
|
||||
if (promt)
|
||||
{
|
||||
cerr<<"enter bin count:";
|
||||
}
|
||||
sin >>in.bin_count;
|
||||
|
||||
return in;
|
||||
return in;
|
||||
}
|
||||
|
||||
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx)
|
||||
@@ -64,17 +63,29 @@ download(const string& adress)
|
||||
if(curl)
|
||||
{
|
||||
CURLcode res;
|
||||
curl_easy_setopt(curl, CORLOPT_URL, adress);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, adress.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA,&buffer);
|
||||
res=curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
|
||||
if(res!=CURLE_OK)
|
||||
{
|
||||
cout<<curl_easy_strerror;
|
||||
exit(1);
|
||||
}
|
||||
if(res== CURLE_ok)
|
||||
{
|
||||
res=curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect);
|
||||
if(CURLE_OK ==res)
|
||||
{
|
||||
cerr<<"connecting time: "<<connect;
|
||||
}
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
|
||||
return input_data(buffer, false);
|
||||
}
|
||||
|
||||
@@ -83,13 +94,13 @@ int main(int arg, char* argv[])
|
||||
{
|
||||
if (arg > 1)
|
||||
{
|
||||
input = download(argv[1]);
|
||||
input = download(argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
input=input_data(cin,true);
|
||||
}
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins);
|
||||
return 0;
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user