|
|
|
@ -32,7 +32,7 @@ Input input_data()
|
|
|
|
|
cin >> in.numbers[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cerr << " number of baskets: ";
|
|
|
|
|
cerr << "Count of baskets: ";
|
|
|
|
|
cin >> in.bin_count;
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
@ -56,9 +56,9 @@ void find_minmax(const vector<double> &numbers, double &min, double &max)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int make_histogram(const vector<double> &numbers, size_t &bin_count)
|
|
|
|
|
vector<int> make_histogram(const vector<double> &numbers, size_t bin_count)
|
|
|
|
|
{
|
|
|
|
|
vector<int> bins(bin_count);
|
|
|
|
|
vector<int> bins(bin_count);
|
|
|
|
|
int max_count = bins[0];
|
|
|
|
|
double min = numbers[0];
|
|
|
|
|
double max = numbers[0];
|
|
|
|
@ -86,60 +86,21 @@ int make_histogram(const vector<double> &numbers, size_t &bin_count)
|
|
|
|
|
bins[bin_count - 1]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < bin_count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (bins[i] > max_count)
|
|
|
|
|
{
|
|
|
|
|
max_count = bins[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bins;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
void show_histogram_text(vector<int> &bins, size_t bin_count)
|
|
|
|
|
{
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
|
|
|
|
|
vector<int> bins(in.bin_count);
|
|
|
|
|
vector<double> height(in.bin_count);
|
|
|
|
|
|
|
|
|
|
int max_count = bins[0];
|
|
|
|
|
double min = in.numbers[0];
|
|
|
|
|
double max = in.numbers[0];
|
|
|
|
|
|
|
|
|
|
find_minmax(in.numbers, min, max);
|
|
|
|
|
|
|
|
|
|
double bin_size = (max - min) / in.bin_count;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < in.numbers.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
|
|
|
|
for (size_t j = 0; (j < in.bin_count - 1) && !found; j++)
|
|
|
|
|
{
|
|
|
|
|
auto lo = min + j * bin_size;
|
|
|
|
|
auto hi = min + (j + 1) * bin_size;
|
|
|
|
|
|
|
|
|
|
if ((lo <= in.numbers[i]) && (in.numbers[i] < hi))
|
|
|
|
|
{
|
|
|
|
|
bins[j]++;
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
bins[in.bin_count - 1]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < in.bin_count; i++)
|
|
|
|
|
for (int i = 0; i < bin_count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (bins[i] > max_count)
|
|
|
|
|
{
|
|
|
|
|
max_count = bins[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < in.bin_count; i++)
|
|
|
|
|
vector<double> height(bin_count);
|
|
|
|
|
for (int i = 0; i < bin_count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (bins[i] > MAX_ASTERISK)
|
|
|
|
|
{
|
|
|
|
@ -149,7 +110,7 @@ int main()
|
|
|
|
|
height[i] = bins[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < in.bin_count; i++)
|
|
|
|
|
for (int i = 0; i < bin_count; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (bins[i] < 100)
|
|
|
|
@ -170,6 +131,12 @@ int main()
|
|
|
|
|
}
|
|
|
|
|
cout << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
auto in = input_data();
|
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
show_histogram_text(bins, in.bin_count);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|