Сравнить коммиты
10 Коммитов
5bd52d8465
...
main
| Автор | SHA1 | Дата | |
|---|---|---|---|
| ba3805c7cd | |||
| 438cacfdb1 | |||
| ed361dae03 | |||
| b9ccc72d62 | |||
| 9e1fbe8dbe | |||
| 54d52ef37d | |||
| d866ad8079 | |||
| 0bdf67a606 | |||
| 97036095fa | |||
| 0eb008b27e |
@@ -36,9 +36,7 @@
|
|||||||
<Unit filename="histogram.h" />
|
<Unit filename="histogram.h" />
|
||||||
<Unit filename="main.cpp" />
|
<Unit filename="main.cpp" />
|
||||||
<Unit filename="svg.cpp" />
|
<Unit filename="svg.cpp" />
|
||||||
<Unit filename="svg.h">
|
<Unit filename="svg.h" />
|
||||||
<Option target="<{~None~}>" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="text.cpp" />
|
<Unit filename="text.cpp" />
|
||||||
<Unit filename="text.h" />
|
<Unit filename="text.h" />
|
||||||
<Extensions>
|
<Extensions>
|
||||||
|
|||||||
61
main.cpp
61
main.cpp
@@ -1,4 +1,7 @@
|
|||||||
|
#include <curl/curl.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
@@ -13,30 +16,62 @@ struct Input {
|
|||||||
Input
|
Input
|
||||||
input_data(istream& in, bool prompt) {
|
input_data(istream& in, bool prompt) {
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
if (prompt) {cerr << "Enter number count: ";}
|
if (prompt) {cerr << "Enter number count: ";};
|
||||||
in >> number_count;
|
in >> number_count;
|
||||||
|
|
||||||
Input in1;
|
Input in1;
|
||||||
in1.numbers.resize(number_count);
|
in1.numbers.resize(number_count);
|
||||||
if (prompt) {cerr << "Enter numbers: ";}
|
if (prompt) {cerr << "Enter numbers: ";};
|
||||||
for (size_t i = 0; i < number_count; i++) {
|
for (size_t i = 0; i < number_count; i++) {
|
||||||
in >> in1.numbers[i];
|
in >> in1.numbers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prompt) {cerr << "Enter bin count: ";}
|
|
||||||
|
if (prompt) {cerr << "Enter bin count: ";};
|
||||||
in >> in1.bin_count;
|
in >> in1.bin_count;
|
||||||
|
|
||||||
return in1;
|
return in1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
static size_t
|
||||||
{
|
write_data(void* items, size_t item_size, size_t item_count, void* ctx){
|
||||||
const size_t SCREEN_WIDTH = 80;
|
size_t data_size = item_size * item_count;
|
||||||
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
||||||
bool prompt = true;
|
buffer->write(reinterpret_cast<const char*>(items), data_size);
|
||||||
|
return data_size;
|
||||||
auto in = input_data(cin, prompt);
|
}
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
||||||
show_histogram_svg(bins);
|
Input
|
||||||
return 0;
|
download(const string& address){
|
||||||
|
stringstream buffer;
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
if(curl) {
|
||||||
|
CURLcode res;
|
||||||
|
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);
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
return input_data(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
#include <curl/curl.h>
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Unit filename="histogram.cpp" />
|
<Unit filename="doctest.h" />
|
||||||
<Unit filename="unittest.cpp" />
|
<Unit filename="unittest.cpp" />
|
||||||
<Extensions>
|
<Extensions>
|
||||||
<lib_finder disable_auto="1" />
|
<lib_finder disable_auto="1" />
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user