code: готовая база
Этот коммит содержится в:
@@ -20,12 +20,12 @@ void find_minmax(const std::vector <double> &numbers, double &min, double &max,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector <int> make_histogram( std::vector<double> &numbers, size_t &bin_count) {
|
std::vector <std::size_t> make_histogram( const std::vector<double> &numbers, std::size_t bin_count) {
|
||||||
double min, max;
|
double min, max;
|
||||||
bool res = false;
|
bool res = false;
|
||||||
find_minmax(numbers, min, max, res);
|
find_minmax(numbers, min, max, res);
|
||||||
double bin_size = ( max - min ) / bin_count;
|
double bin_size = ( max - min ) / bin_count;
|
||||||
std::vector<int> bins ( bin_count );
|
std::vector<std::size_t> bins ( bin_count );
|
||||||
for (std::size_t i=0; i < numbers.size(); i++ ){
|
for (std::size_t i=0; i < numbers.size(); i++ ){
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (std::size_t j = 0; ( j < bin_count - 1 ) && !found; j++ ){
|
for (std::size_t j = 0; ( j < bin_count - 1 ) && !found; j++ ){
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
std::vector<int>
|
std::vector <std::size_t> make_histogram(const std::vector<double> &numbers, std::size_t bin_count);
|
||||||
make_histogram(const std::vector<double> &numbers, std::size_t &bin_count);
|
|
||||||
|
|
||||||
#endif // HISTOGRAM_H_INCLUDED
|
#endif // HISTOGRAM_H_INCLUDED
|
||||||
|
|||||||
2
svg.cpp
2
svg.cpp
@@ -27,7 +27,7 @@ void svg_rect(double x, double y, double width, double height){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_svg(const std::vector <int> bins) {
|
show_histogram_svg(const std::vector <std::size_t> &bins) {
|
||||||
|
|
||||||
const auto IMAGE_WIDTH = 400;
|
const auto IMAGE_WIDTH = 400;
|
||||||
const auto IMAGE_HEIGHT = 300;
|
const auto IMAGE_HEIGHT = 300;
|
||||||
|
|||||||
3
svg.h
3
svg.h
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
void
|
void show_histogram_svg(const std::vector<std::size_t> &bins);
|
||||||
show_histogram_svg(const std::vector<int> &bins);
|
|
||||||
|
|
||||||
#endif // SVG_H_INCLUDED
|
#endif // SVG_H_INCLUDED
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user