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

..

Ничего общего в коммитах. '1b1311833a40a0cc7e3ce1389f82203913404a27' и '2eaf79429552ea1a12e3b581eeb87f758e6e8269' имеют совершенно разные истории.

@ -27,7 +27,7 @@ find_minmax(const vector<double>& numbers, double& min, double& max) {
return flag; return flag;
} }
vector<size_t> make_histogram(const vector<double> numbers, size_t bin_count){ vector<size_t> make_histogram(const vector<double> numbers, size_t bin_count, bool& flag){
vector<size_t> bins(bin_count); vector<size_t> bins(bin_count);
double max, min = 0; double max, min = 0;
find_minmax(numbers, min, max); find_minmax(numbers, min, max);

@ -4,6 +4,6 @@
#include <vector> #include <vector>
std::vector<size_t> std::vector<size_t>
make_histogram(const std::vector<double> numbers, size_t bin_count); make_histogram(const std::vector<double> numbers, size_t bin_count, bool& flag);
#endif // HISTOGRAM_H_INCLUDED #endif // HISTOGRAM_H_INCLUDED

@ -6,8 +6,6 @@
#include <text.h> #include <text.h>
#include <svg.h> #include <svg.h>
#include <curl/curl.h> #include <curl/curl.h>
#include <sstream>
using namespace std; using namespace std;
@ -25,7 +23,7 @@ Input
input_data(istream& in, bool prompt) { input_data(istream& in, bool prompt) {
if (prompt == true) { if (prompt == true) {
size_t number_count; size_t number_count;
cerr << "input number count"; cerr << "amount of numbers";
in >> number_count; in >> number_count;
Input inn; Input inn;
inn.numbers.resize(number_count); inn.numbers.resize(number_count);
@ -36,13 +34,14 @@ input_data(istream& in, bool prompt) {
} }
size_t bin_count; size_t bin_count;
cerr << "input amount of bins"; cerr << "amount of baskets";
in >> inn.bin_count; in >> inn.bin_count;
return inn; return inn;
} }
else {
else if (prompt == false) {
size_t number_count; size_t number_count;
cout << "input number count"; cout << "amount of numbers";
in >> number_count; in >> number_count;
Input inn; Input inn;
inn.numbers.resize(number_count); inn.numbers.resize(number_count);
@ -53,58 +52,35 @@ return inn;
} }
size_t bin_count; size_t bin_count;
cout << "input amount of bins"; cout << "input baskets";
in >> inn.bin_count; in >> inn.bin_count;
return inn; return inn;
} }
} }
static 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(reinterpret_cast<const char*>(items), data_size);
return data_size;
}
Input
download(const string& address) {
stringstream buffer;
CURL* curl = curl_easy_init();
if(curl)
{
CURLcode res;
const char* res2;
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!=0)
{
res2=curl_easy_strerror(res);
cout<<res2<<endl;
exit(1);
}
curl_easy_cleanup(curl);
}
curl_global_init(CURL_GLOBAL_ALL);
return input_data(buffer, true);
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
Input in;
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if (argc > 1) { if(curl) {
in = download(argv[1]); CURLcode res;
} else { curl_easy_setopt(curl, CURLOPT_URL, "http://uit.mpei.ru/study/courses/cs/lab03/marks.txt");
in = input_data(cin, true); res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
return 0;
} }
auto bins = make_histogram(in.numbers, in.bin_count);
auto procent = make_histogram_proc(in.numbers, in.bin_count, bins);
bool flag;
bool prompt;
prompt = true;
auto inn = input_data(cin, prompt);
auto bins = make_histogram(inn.numbers, inn.bin_count, flag);
auto procent = make_histogram_proc(inn.numbers, inn.bin_count, bins);
show_histogram_svg(bins, procent); show_histogram_svg(bins, procent);
return 0; return 0;

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