|
|
@ -6,18 +6,31 @@ using namespace std;
|
|
|
|
const size_t SCREEN_WIDTH = 80;
|
|
|
|
const size_t SCREEN_WIDTH = 80;
|
|
|
|
const size_t MAX_LENGTH = SCREEN_WIDTH - 3 - 1;
|
|
|
|
const size_t MAX_LENGTH = SCREEN_WIDTH - 3 - 1;
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
struct Input {
|
|
|
|
int number_count, bin_count, i, j;
|
|
|
|
vector<double> numbers;
|
|
|
|
cerr << "Enter number count:" << endl;
|
|
|
|
size_t bin_count{};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Input
|
|
|
|
|
|
|
|
input_data(){
|
|
|
|
|
|
|
|
size_t number_count;
|
|
|
|
cin >> number_count;
|
|
|
|
cin >> number_count;
|
|
|
|
|
|
|
|
Input in;
|
|
|
|
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
vector<double> numbers(number_count);
|
|
|
|
vector<double> numbers(number_count);
|
|
|
|
cerr << "Enter numbers:" << endl;
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
for (i = 0;i < number_count; i++) {
|
|
|
|
cin >> in.numbers[i];
|
|
|
|
cin >> numbers[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto min = numbers[0];
|
|
|
|
cin >> in.bin_count;
|
|
|
|
auto max = numbers[0];
|
|
|
|
return in;
|
|
|
|
for (auto x : numbers) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
|
|
|
main() {
|
|
|
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
|
|
|
auto min = in.numbers[0];
|
|
|
|
|
|
|
|
auto max = in.numbers[0];
|
|
|
|
|
|
|
|
for (auto x : in.numbers) {
|
|
|
|
if (x < min) {
|
|
|
|
if (x < min) {
|
|
|
|
min = x;
|
|
|
|
min = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -25,19 +38,17 @@ int main() {
|
|
|
|
max = x;
|
|
|
|
max = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cerr << "Enter bin count:" << endl;
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
|
|
cin >> bin_count;
|
|
|
|
vector<size_t> bins(in.bin_count);
|
|
|
|
double bin_size = (max - min) / bin_count;
|
|
|
|
for (auto i = 0; i < in.number_count; i++) {
|
|
|
|
vector<size_t> bins(bin_count);
|
|
|
|
|
|
|
|
for (i = 0; i < number_count; i++) {
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
bool found = false;
|
|
|
|
for (j = 0; (j < bin_count - 1) && !found ; j++) {
|
|
|
|
for (auto j = 0; (j < in.bin_count - 1) && !found ; j++) {
|
|
|
|
if ((min + j * bin_size <= numbers[i]) && (numbers[i] < min + (j + 1) * bin_size)) {
|
|
|
|
if ((min + j * bin_size <= in.numbers[i]) && (in.numbers[i] < min + (j + 1) * bin_size)) {
|
|
|
|
bins[j] += 1;
|
|
|
|
bins[j] += 1;
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) bins[bin_count - 1]++;
|
|
|
|
if (!found) bins[in.bin_count - 1]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto max_count = bins[0];
|
|
|
|
auto max_count = bins[0];
|
|
|
|
for (auto x : bins) {
|
|
|
|
for (auto x : bins) {
|
|
|
@ -45,7 +56,7 @@ int main() {
|
|
|
|
max_count = x;
|
|
|
|
max_count = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < bin_count; i++) {
|
|
|
|
for (i = 0; i < in.bin_count; i++) {
|
|
|
|
j = 100;
|
|
|
|
j = 100;
|
|
|
|
while (bins[i] < j) {
|
|
|
|
while (bins[i] < j) {
|
|
|
|
cout << " ";
|
|
|
|
cout << " ";
|
|
|
|