|
|
@ -4,29 +4,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
struct Input
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
vector<double> numbers;
|
|
|
|
size_t number_count;
|
|
|
|
size_t bin_count{};
|
|
|
|
const size_t screen_width = 80;
|
|
|
|
};
|
|
|
|
const size_t max_asterisk = screen_width - 3 - 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cerr << "Enter number count : ";
|
|
|
|
Input input_data()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
size_t number_count;
|
|
|
|
cin >> number_count;
|
|
|
|
cin >> number_count;
|
|
|
|
vector <double> numbers(number_count);
|
|
|
|
|
|
|
|
cerr << "Enter numbers : " << endl;
|
|
|
|
Input in;
|
|
|
|
for (i = 0; i < number_count; i++)
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < number_count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cin >> numbers[i];
|
|
|
|
cin >> in.numbers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size_t bin_count;
|
|
|
|
cin>> in.bin_count;
|
|
|
|
cerr << "Enter bin count : ";
|
|
|
|
return in;
|
|
|
|
cin >> bin_count;
|
|
|
|
}
|
|
|
|
vector <size_t> bins(bin_count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const size_t screen_width = 80;
|
|
|
|
|
|
|
|
const size_t max_asterisk = screen_width - 3 - 1;
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
|
|
double min = numbers[0];
|
|
|
|
|
|
|
|
double max = numbers[0];
|
|
|
|
Input in = input_data();
|
|
|
|
for (double x : numbers)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector <size_t> bins(in.bin_count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double min = in.numbers[0];
|
|
|
|
|
|
|
|
double max = in.numbers[0];
|
|
|
|
|
|
|
|
for (double x : in.numbers)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (x < min)
|
|
|
|
if (x < min)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -38,16 +54,16 @@ int main()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double bin_size = (max - min) / bin_count;
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < number_count; i++)
|
|
|
|
for (size_t i = 0; i < in.numbers.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
bool found = false;
|
|
|
|
for (size_t j = 0; (j < bin_count - 1) && !found; j++)
|
|
|
|
for (size_t j = 0; (j < in.bin_count - 1) && !found; j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto lo = min + j * bin_size;
|
|
|
|
auto lo = min + j * bin_size;
|
|
|
|
auto hi = min + (j + 1) * bin_size;
|
|
|
|
auto hi = min + (j + 1) * bin_size;
|
|
|
|
if ((lo <= numbers[i]) && (numbers[i] < hi))
|
|
|
|
if ((lo <= in.numbers[i]) && (in.numbers[i] < hi))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bins[j] ++;
|
|
|
|
bins[j] ++;
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
@ -55,13 +71,13 @@ int main()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bins[bin_count - 1]++;
|
|
|
|
bins[in.bin_count - 1]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double max_count;
|
|
|
|
double max_count;
|
|
|
|
max_count = bins[0];
|
|
|
|
max_count = bins[0];
|
|
|
|
for (i=0; i< bin_count; i++)
|
|
|
|
for (i=0; i< in.bin_count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (max_count<bins[i])
|
|
|
|
if (max_count<bins[i])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -75,7 +91,7 @@ int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
flag=true;
|
|
|
|
flag=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (j = 0; j < bin_count; j++)
|
|
|
|
for (j = 0; j < in.bin_count; j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (bins[j] < 100)
|
|
|
|
if (bins[j] < 100)
|
|
|
|
{
|
|
|
|
{
|
|
|
|