code: Загрузка данных по сети

master
EfremovSI 1 год назад
Родитель 7bd4bee170
Сommit d5a9d78924

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

@ -1,2 +1,3 @@
/bin
/obj
/curl

@ -1,6 +1,7 @@
#include <iostream>
#include <vector>
#include "hist_proc.h"
#include "hist_proc_internal.h"
using namespace std;
vector<size_t> make_histogram_proc(const vector<double> numbers, size_t bin_count, vector<size_t> bins){
vector<size_t> procent(bin_count);

@ -4,8 +4,14 @@
using namespace std;
static void
bool
find_minmax(const vector<double>& numbers, double& min, double& max) {
bool flag;
if (numbers.size() == 0){
flag=false;
}
else {
min = numbers[0];
max = numbers[0];
for (double x : numbers) {
@ -18,7 +24,10 @@ find_minmax(const vector<double>& numbers, double& min, double& max) {
}
}
vector<size_t> make_histogram(const vector<double> numbers, size_t bin_count){
return flag;
}
vector<size_t> make_histogram(const vector<double> numbers, size_t bin_count, bool& flag){
vector<size_t> bins(bin_count);
double max, min = 0;
find_minmax(numbers, min, max);

@ -4,6 +4,6 @@
#include <vector>
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

@ -5,7 +5,7 @@
#include "histogram.h"
#include <text.h>
#include <svg.h>
#include <curl/curl.h>
using namespace std;
@ -20,28 +20,54 @@ struct Input {
Input
input_data(istream& in) {
input_data(istream& in, bool prompt) {
if (prompt == true) {
size_t number_count;
cerr << "amount of numbers";
in >> number_count;
Input inn;
inn.numbers.resize(number_count);
vector<double> numbers(number_count);
cerr << "input numbers";
for (size_t i = 0; i < number_count; i++) {
in >> inn.numbers[i];
}
size_t bin_count;
cerr << "amount of baskets";
in >> inn.bin_count;
return inn;
}
else if (prompt == false) {
size_t number_count;
cout << "amount of numbers";
in >> number_count;
Input inn;
inn.numbers.resize(number_count);
vector<double> numbers(number_count);
cout << "input numbers";
for (size_t i = 0; i < number_count; i++) {
in >> inn.numbers[i];
}
size_t bin_count;
cout << "input baskets";
in >> inn.bin_count;
return inn;
}
}
int main()
{
curl_global_init(CURL_GLOBAL_ALL);
bool flag;
auto inn = input_data(cin);
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);

@ -9,4 +9,9 @@ TEST_CASE("distinct positive numbers") {
CHECK(procent[0] == 33);
CHECK(procent[1] == 33);
CHECK(procent[2] == 34);
procent = make_histogram_proc({1}, 3, {1, 0, 0});
CHECK(procent[0] == 100);
CHECK(procent[1] == 0);
CHECK(procent[2] == 0);
}

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