|
|
|
@ -24,13 +24,11 @@ input_data(){
|
|
|
|
|
cin >> in.bin_count;
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main() {
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
auto min = in.numbers[0];
|
|
|
|
|
auto max = in.numbers[0];
|
|
|
|
|
for (auto x : in.numbers) {
|
|
|
|
|
static void
|
|
|
|
|
find_minmax(const std::vector<double>& numbers, double& min, double& max){
|
|
|
|
|
min = numbers[0];
|
|
|
|
|
max = numbers[0];
|
|
|
|
|
for (auto x : numbers) {
|
|
|
|
|
if (x < min) {
|
|
|
|
|
min = x;
|
|
|
|
|
}
|
|
|
|
@ -38,12 +36,19 @@ main() {
|
|
|
|
|
max = x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int
|
|
|
|
|
main() {
|
|
|
|
|
size_t i, j;
|
|
|
|
|
double min, max;
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
find_minmax (in.numbers, min, max);
|
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
|
|
|
vector<size_t> bins(in.bin_count);
|
|
|
|
|
for (auto i = 0; i < in.number_count; i++) {
|
|
|
|
|
for (auto x : in.numbers) {
|
|
|
|
|
bool found = false;
|
|
|
|
|
for (auto j = 0; (j < in.bin_count - 1) && !found ; j++) {
|
|
|
|
|
if ((min + j * bin_size <= in.numbers[i]) && (in.numbers[i] < min + (j + 1) * bin_size)) {
|
|
|
|
|
for (j = 0; (j < (in.bin_count - 1) && !found); j++) {
|
|
|
|
|
if (min + j * bin_size <= x && (x < min + (j + 1) * bin_size)) {
|
|
|
|
|
bins[j] += 1;
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|