ArtyushinaVV 2 лет назад
Родитель 68604d9c90
Сommit 5b097b21eb

@ -63,13 +63,15 @@ download(const string& address) {
{ {
CURLcode res; CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); 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); res = curl_easy_perform(curl);
if (res != 0) if (res != 0)
{ {
cout << curl_easy_strerror(res); cout << curl_easy_strerror(res);
exit(1); exit(1);
} }
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &buffer);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
@ -79,14 +81,44 @@ download(const string& address) {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int ind;
const char* format;
Input input; Input input;
if (argc > 1) { if (argc > 1)
{
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], static_cast<const char*>("-format")) == 0) //Ôóíêöèÿ strcmp âûïîëíÿåò ïîðÿäêîâîå ñðàâíåíèå ñòðîê; static_cast ïðèìåíÿåòñÿ äëÿ ïðèâåäåíèÿ òèïîâ
{
ind = i;
}
}
if ((ind+1) < argc)
{
format = argv[ind + 1];
if (!(strcmp(format, static_cast<const char*>("text")) == 0) && !(strcmp(format, static_cast<const char*>("svg")) == 0))
{
cout << "unknown format";
return 0;
}
}
else
{
cout << "write program format";
return 0;
}
input = download(argv[1]); input = download(argv[1]);
} else { }
else
{
input = input_data(cin, true); input = input_data(cin, true);
} }
const auto bins = make_histogram(input.numbers, input.bin_count); const auto bins = make_histogram(input.numbers, input.bin_count);
show_histogram_svg(bins);
return 0; if (strcmp(format, static_cast<const char*>("text")) == 0) {
show_histogram_text(bins, input.bin_count); }
else if (strcmp(format, static_cast<const char*>("svg")) == 0) {
show_histogram_svg(bins); }
} }

Загрузка…
Отмена
Сохранить