#include
#include
#include
int rand_num(int min, int max)
{
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution uni(min, max);
auto random_integer = uni(rng);
return random_integer;
}
int sum_vec(std::vector v)
{
int sum = 0;
for (auto &num : v)
{
sum += num;
}
return sum;
}
void print_vec_2d(const std::vector>& v)
{
for (int i = 0; i < v.size(); ++i)
{
for (int j = 0; j < v[i].size(); ++j)
{
std::cout << v[i][j] << " ";</p>
}
std::cout << std::endl;</p>
}
}
void sort_vec_2d(std::vector>& v)
{
for (int i = 0; i < v.size(); ++i)
{
for (int j = i + 1; j < v.size(); ++j)
{
if (sum_vec(v[i]) > sum_vec(v[j]))
{
std::swap(v[i], v[j]);
}
}
}
}
void rand_vec_2d(std::vector>& v, int min, int max)
{
v.resize(rand_num(min, max));
for (int i = 0; i < v.size(); ++i)
{
for (int j = 0; j < rand_num(min, max); ++j)
{
v[i].push_back(rand_num(min, max));
}
}
}
int main()
{
setlocale(LC_ALL, "Russian");
std::vector> nums;
rand_vec_2d(nums, 1, 10);
std::cout << "Исходынй вектор: " << std::endl;</p>
print_vec_2d(nums);
sort_vec_2d(nums);
std::cout << "Полученный вектор: " << std::endl;</p>
print_vec_2d(nums);
//system("pause");
}