Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
59 строки
1002 B
C++
59 строки
1002 B
C++
#include <iostream>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
struct Input
|
|
{
|
|
vector<double> numbers;
|
|
size_t bin_count{};
|
|
};
|
|
|
|
|
|
Input
|
|
input_data()
|
|
{
|
|
Input in;
|
|
size_t number_count;
|
|
cin>>number_count;
|
|
in.numbers.resize(number_count);
|
|
|
|
vector <double> numbers(number_count);
|
|
cout<<endl;
|
|
for(size_t i=0; i<number_count; i++)
|
|
{
|
|
cin>>in.numbers[i];
|
|
}
|
|
|
|
size_t bin_count;
|
|
cin>>in.bin_count;
|
|
vector<size_t> bins(bin_count);
|
|
return in;
|
|
}
|
|
|
|
void find_minmax(const vector<double>& numbers, double& min, double& max)
|
|
{
|
|
min = numbers[0];
|
|
max = numbers[0];
|
|
for (double x : numbers)
|
|
{
|
|
if (x < min)
|
|
{
|
|
min = x;
|
|
}
|
|
else if (x > max)
|
|
{
|
|
max = x;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
int main()
|
|
{
|
|
Input in = input_data();
|
|
double min, max;
|
|
vector<double> numbers;
|
|
find_minmax( numbers, min, max);
|
|
}
|