Сравнить коммиты
2 Коммитов
3488801792
...
0dac6860b1
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
0dac6860b1 | ||
|
|
ca54d0f95d |
107
main.cpp
107
main.cpp
@@ -4,93 +4,86 @@
|
|||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//const size_t SCREEN_WIDTH = 80;
|
|
||||||
//const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
|
||||||
|
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
size_t IMAGE_WIDTH{};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Input
|
Input input_data(istream &in, bool promt)
|
||||||
input_data(istream& in, bool promt)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t number_count, bin_count, IMAGE_WIDTH;
|
size_t number_count, bin_count;
|
||||||
|
|
||||||
if (promt) cerr << "Enter number count: ";
|
if (promt)
|
||||||
|
cerr << "Enter number count: ";
|
||||||
in >> number_count;
|
in >> number_count;
|
||||||
|
|
||||||
Input input;
|
Input input;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (promt) cerr << " Input width of image, > 70 but not >800 : ";
|
|
||||||
in >> input.IMAGE_WIDTH;
|
|
||||||
if(input.IMAGE_WIDTH < 70 || input.IMAGE_WIDTH > 800 ) {
|
|
||||||
while(input.IMAGE_WIDTH < 70 || input.IMAGE_WIDTH > 800) {
|
|
||||||
if (promt) cerr << " Input width of image, >70 but not >800 : ";
|
|
||||||
in >> input.IMAGE_WIDTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//size_t number_count = in.number_counts;
|
|
||||||
|
|
||||||
input.numbers.resize(number_count);
|
input.numbers.resize(number_count);
|
||||||
if (promt) cerr << "Enter numbers: ";
|
if (promt)
|
||||||
// vector<double> numbers(number_count);
|
cerr << "Enter numbers: ";
|
||||||
|
|
||||||
for (size_t i = 0; i < number_count; i++)
|
for (size_t i = 0; i < number_count; i++)
|
||||||
{
|
{
|
||||||
in >> input.numbers[i];
|
in >> input.numbers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promt) cerr << "Count of baskets: ";
|
if (promt)
|
||||||
|
cerr << "Count of baskets: ";
|
||||||
in >> input.bin_count;
|
in >> input.bin_count;
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
Input download(const string &address)
|
||||||
main(int argc, char* argv[])
|
|
||||||
{
|
{
|
||||||
|
stringstream buffer;
|
||||||
|
|
||||||
if( argc > 1 ){
|
//address.c_str();
|
||||||
|
|
||||||
CURL* curl = curl_easy_init();
|
|
||||||
|
|
||||||
cout << argc << '\n';
|
|
||||||
//while (true)
|
|
||||||
for (int i = 0; i < argc; i++){
|
|
||||||
|
|
||||||
cout << argv[i] << " ";
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
{
|
||||||
auto input = input_data(cin, true);
|
CURL *curl = curl_easy_init();
|
||||||
auto bins = make_histogram( input.numbers, input.bin_count );
|
if (curl)
|
||||||
//int chek_block_width(in.IMAGE_WIDTH);
|
{
|
||||||
//chek_block_width(in.IMAGE_WIDTH, in.number_count);
|
CURLcode res;
|
||||||
//if (chek_block_width==1)
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
show_histogram_svg( bins, input.IMAGE_WIDTH );
|
res = curl_easy_perform(curl);
|
||||||
//if(chek_block_width==0) return 0;
|
CURL *curl = curl_easy_init();
|
||||||
//show_histogram_svg(bins);
|
if (curl)
|
||||||
|
{
|
||||||
|
CURLcode res;
|
||||||
|
/* set options */
|
||||||
|
/* Perform the entire transfer */
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
/* Check for errors */
|
||||||
|
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[]) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user