lab4
KhodiukMR 11 месяцев назад
Родитель fe6d5ade72
Сommit ac8f41c554

@ -9,6 +9,7 @@
using namespace std; using namespace std;
struct Input { struct Input {
vector<double> Numbers; vector<double> Numbers;
size_t BinCount{}; size_t BinCount{};
@ -48,21 +49,29 @@ WriteData(void* items, size_t item_size, size_t item_count, void* ctx) {
} }
Input Input
Download(const string& address) { Download(const string& address, const string& option) {
stringstream buffer; stringstream buffer;
if ((option != "") && (address != "-verbose") && (option != "-verbose")) {
cout << "õóéíþ òû ïèøåøü, ïèøè îïöèþ -verbose, äààóí" << endl;
exit(2);
}
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
if (curl) { if (curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); CURLcode res;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData); curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData);
res = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
if (res != CURLE_OK) { if (address == "-verbose" || option == "-verbose") {
cout << curl_easy_strerror(res); curl_easy_setopt(curl, CURLOPT_VERBOSE, option == "-verbose" ? option.c_str() : address.c_str());
exit(1); }
} res = curl_easy_perform(curl);
curl_easy_cleanup(curl); if (res != CURLE_OK) {
cout << curl_easy_strerror(res);
exit(1);
}
curl_easy_cleanup(curl);
} }
@ -72,10 +81,11 @@ Download(const string& address) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
setlocale(LC_ALL, "Russian");
double MaxCount = 0; double MaxCount = 0;
Input in; Input in;
if (argc > 1) { if (argc > 1) {
in = Download(argv[1]); in = Download(argv[1], argv[2]);
} }
else { else {
in = InputData(cin, true); in = InputData(cin, true);

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