Sasha (KobzevAV) 2 лет назад
Родитель 55311054d0
Сommit 8075d1e0d9

@ -45,17 +45,6 @@ write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
return data_size; return data_size;
} }
string
filling(const string& key, const string& color){
if(strcmp(key.c_str(), "-fill") == 0){
if (strcmp(color.c_str(), " ") == 0){
cerr << "Error: no color specified";
exit(1);
}
return color.c_str();
}
}
Input Input
download(const string& adress){ download(const string& adress){
stringstream buffer; stringstream buffer;
@ -68,6 +57,7 @@ download(const string& adress){
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != CURLE_OK){ if (res != CURLE_OK){
cerr << curl_easy_strerror(res); cerr << curl_easy_strerror(res);
exit(1); exit(1);
} }
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
@ -80,20 +70,28 @@ int main(int argc, char* argv[]){
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
Input in; Input in;
if (argc > 1) { if (argc > 1) {
in = download(argv[1]); for (size_t i = 0; i < argc; i += 1){
} else { if (strcmp(argv[i], "-fill") == 0){
in = input_data(cin, true); if (i - 1 < 1){
in = download(argv[i + 2]);
color = argv[i + 1];
} }
else{
if (argc > 2){ if (i + 1 >= argc){
if (argv[3] == NULL){ cerr << "Error: please enter color";
color = filling(argv[2], " "); exit(1);
} }
else{ else{
color = filling(argv[2], argv[3]); in = download(argv[i - 1]);
color = argv[i + 1];
} }
} }
}
}
}
else {
in = input_data(cin, true);
}
auto bins = make_histogram(in.numbers, in.bin_count); auto bins = make_histogram(in.numbers, in.bin_count);
auto borders = make_borders(in.numbers, in.bin_count); auto borders = make_borders(in.numbers, in.bin_count);
show_histogram_svg(bins, borders, in.bin_count, color); show_histogram_svg(bins, borders, in.bin_count, color);

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