diff --git a/bin/Debug/devlab1.exe b/bin/Debug/devlab1.exe index aaebcd8..e209b2a 100644 Binary files a/bin/Debug/devlab1.exe and b/bin/Debug/devlab1.exe differ diff --git a/main.cpp b/main.cpp index a70144c..9ef49d5 100644 --- a/main.cpp +++ b/main.cpp @@ -2,26 +2,30 @@ #include using namespace std; -struct Input { +struct Input +{ vector numbers; size_t bin_count; }; Input -input_data(){ +input_data() +{ size_t number_count; cin >> number_count; Input in; in.numbers.resize(number_count); - for (size_t i = 0; i < number_count; i++) { + for (size_t i = 0; i < number_count; i++) + { cin >> in.numbers[i]; } -size_t bin_count; -cin >> bin_count; + size_t bin_count; + cin >> bin_count; return in; } void -find_minmax(const vector& numbers, double& min, double& max) { +find_minmax(const vector& numbers, double& min, double& max) +{ min = numbers[0]; max = numbers[0]; for ( size_t i=0; i < numbers.size(); i++) @@ -32,12 +36,13 @@ find_minmax(const vector& numbers, double& min, double& max) { }; std::vector -make_histogram(const vector& numbers,size_t bin_count){ -float lo,hi,dif; -double min, max; -find_minmax(numbers, min, max); -vector bins(bin_count) ; -dif=(max - min)/bin_count; +make_histogram(const vector& numbers,size_t bin_count) +{ + float lo,hi,dif; + double min, max; + find_minmax(numbers, min, max); + vector bins(bin_count) ; + dif=(max - min)/bin_count; for(int i=0; i < numbers.size(); i++) { bool found = false; @@ -58,11 +63,26 @@ dif=(max - min)/bin_count; } return bins; } - +void show_histogram_text(vector &bins) +{ + for (size_t i=0; i