|
|
|
@ -1,47 +1,61 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
struct Input {
|
|
|
|
|
vector<double> numbers;
|
|
|
|
|
size_t bin_count{};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input
|
|
|
|
|
input_data() {
|
|
|
|
|
size_t number_count;
|
|
|
|
|
cin >> number_count;
|
|
|
|
|
Input in;
|
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
|
cin >> in.numbers[i];
|
|
|
|
|
}
|
|
|
|
|
cin >> in.bin_count;
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void find_minmax(const vector<double>& numbers, double& min, double& max) {
|
|
|
|
|
min = numbers[0];
|
|
|
|
|
for (double x : numbers){
|
|
|
|
|
if (x < min){
|
|
|
|
|
min = x;
|
|
|
|
|
}
|
|
|
|
|
if (x > max){
|
|
|
|
|
max = x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
// Øèðèíà ýêðàíà äëÿ âûâîäà ãèñòîãðàììû
|
|
|
|
|
const size_t SCREEN_WIDTH = 80;
|
|
|
|
|
// Óâåëè÷åíà øèðèíà äëÿ ïîäïèñåé
|
|
|
|
|
const size_t MAX_ASTERISK = SCREEN_WIDTH - 10;
|
|
|
|
|
Input in = input_data();
|
|
|
|
|
|
|
|
|
|
setlocale(LC_ALL, "rus");
|
|
|
|
|
size_t number_count;
|
|
|
|
|
cerr << "Ââåäèòå êîëè÷åñòâî çíà÷åíèé: ";
|
|
|
|
|
cin >> number_count;
|
|
|
|
|
|
|
|
|
|
vector<double> numbers(number_count);
|
|
|
|
|
for (int i = 0; i < number_count; i++)
|
|
|
|
|
{
|
|
|
|
|
cerr << "Ââåäèòå ÷èñëî ïîä íîìåðîì " << i+1 << ": ";
|
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
|
cin >> numbers[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t bin_count;
|
|
|
|
|
cerr << "Ââåäèòå êîëè÷åñòâî êîðçèí: ";
|
|
|
|
|
cin >> bin_count;
|
|
|
|
|
|
|
|
|
|
vector <size_t> bins(bin_count);
|
|
|
|
|
|
|
|
|
|
double min = numbers[0];
|
|
|
|
|
double max = numbers[0];
|
|
|
|
|
for (double x : numbers)
|
|
|
|
|
{
|
|
|
|
|
if (x < min)
|
|
|
|
|
{
|
|
|
|
|
min = x;
|
|
|
|
|
}
|
|
|
|
|
if (x > max)
|
|
|
|
|
{
|
|
|
|
|
max = x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
find_minmax(in.numbers, min, max);
|
|
|
|
|
cerr<<min;
|
|
|
|
|
cerr<<max;
|
|
|
|
|
double bin_size = (max - min) / bin_count;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < number_count; i++)
|
|
|
|
@ -90,8 +104,6 @@ int main()
|
|
|
|
|
cout << "*";
|
|
|
|
|
}
|
|
|
|
|
cout << endl;
|
|
|
|
|
min1+= bin_size;
|
|
|
|
|
cout << min1<< endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|