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

..

8 Коммитов

1
.gitignore поставляемый

@ -1,5 +1,6 @@
/bin /bin
/obj /obj
/curl
lab03.depend lab03.depend
unittest.depend unittest.depend
unittest.layout unittest.layout

@ -1,8 +1,11 @@
#include <iostream> #include <iostream>
#include <curl/curl.h>
#include <vector> #include <vector>
#include "histogram.h" #include "histogram.h"
#include "text.h" #include "text.h"
#include "svg.h" #include "svg.h"
#include <sstream>
#include <string>
using namespace std; using namespace std;
@ -13,33 +16,74 @@ struct Input {
}; };
Input Input
input_data() { input_data(istream& in, bool prompt) {
Input in; Input local;
size_t number_count; size_t number_count;
size_t bin_count; size_t bin_count;
cerr << "Enter number count: "; if (prompt) {
cin >> in.number_count; cerr << "Enter number count: ";
cerr << "Enter bin count: "; }
cin >> in.bin_count; in >> local.number_count;
if (prompt) {
cerr << "Enter bin count: ";
}
in >> local.bin_count;
in.numbers.resize(in.number_count); local.numbers.resize(local.number_count);
for (size_t i = 0; i < in.number_count; i++) { for (size_t i = 0; i < local.number_count; i++) {
cin >> in.numbers[i]; in >> local.numbers[i];
} }
return in; return local;
}; };
int main() { Input
download (const string& address) {
stringstream buffer;
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
cerr << curl_easy_strerror(res);
exit(1);
}
curl_easy_cleanup(curl);
}
return input_data(buffer, false);
}
size_t
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
size_t data_size = item_size * item_count;
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
buffer->write(static_cast<char*>(items), data_size);
return data_size;
}
int main(int argc, char* argv[]) {
std::string fill = "red"; std::string fill = "red";
std::string stroke = "#000000"; std::string stroke = "#000000";
auto in = input_data(); curl_global_init(CURL_GLOBAL_ALL);
auto bins = make_histogram(in.numbers, in.bin_count);
Input input;
if (argc > 1) {
input = download(argv[1]);
} else {
input = input_data(cin, true);
}
const auto bins = make_histogram(input.numbers, input.bin_count);
show_histogram_svg(bins, fill, stroke); show_histogram_svg(bins, fill, stroke);
return 0; return 0;
} }

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