Сравнить коммиты

..

5 Коммитов

@ -2,6 +2,7 @@
#include <math.h> #include <math.h>
#include <iostream> #include <iostream>
#include <conio.h> #include <conio.h>
#include <curl/curl.h>
#include "histogram.h" #include "histogram.h"
#include "text.h" #include "text.h"
#include "svg.h" #include "svg.h"
@ -11,19 +12,44 @@ struct Input {
size_t bin_count{}; size_t bin_count{};
}; };
Input Input
input_data(){ input_data(istream& in, bool prompt){
cerr << "Do you need hints? Type 0 for no, 1 for yes: ";
int ans;
int state = 0;
while (state ==0){
in >> ans;
if (ans==1) {prompt = true; state=1;}
else if (ans==0) {prompt = false; state=1;}
else cerr << "Invalid data. Please type only 0 or 1: ";
}
size_t number_count; size_t number_count;
cin >> number_count; if (prompt == true) cerr << "Enter number count: ";
Input in; in >> number_count;
in.numbers.resize(number_count); Input input;
input.numbers.resize(number_count);
if (prompt == true) cerr << "Enter numbers: ";
for (size_t i = 0; i < number_count; i++){ for (size_t i = 0; i < number_count; i++){
cin >> in.numbers[i]; in >> input.numbers[i];
} }
cin >> in.bin_count; if (prompt == true) cerr << "Enter bin count: ";
return in; in >> input.bin_count;
return input;
} }
int main(){ int main(int argc, char* argv[]){
auto in = input_data(); if (argc >1 ){
CURL* curl = curl_easy_init();
if(curl){
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
res = curl_easy_perform(curl);
if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
curl_easy_cleanup(curl);
return 0;
curl_global_init(CURL_GLOBAL_ALL);
}
bool prompt;
auto in = input_data(cin, prompt);
auto bins = make_histogram(in.numbers, in.bin_count); auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_svg(bins); show_histogram_svg(bins);
} }

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