#include
#include
#include
#include
#include
#include
#include
const size_t
N = 5,
M = 4;
int main()
{
std::setlocale(LC_ALL, "Russian");
std::random_device random;
std::default_random_engine generator(random());
std::uniform_int_distribution dist(-100, 50);
std::array arr[N];
std::for_each(arr, arr+N, [&dist, &generator](auto& var)
{
std::for_each(var.begin(), var.end(), [&dist, &generator](auto& var)
{
var = dist(generator);
});
});
std::for_each(arr, arr+N, [](auto& var)
{
std::copy(var.begin(), var.end(),
std::ostream_iterator(std::cout, " "));
std::cout
});
std::array sum_min{ 0 };
for (size_t j = 0u; j < M; j++)
{
for (size_t i = 0u; i < N; i++)
{
if (arr[i][j] < 0)
sum_min[j] += arr[i][j];
}
}
std::cout
std::copy(sum_min.begin(), sum_min.end(),
std::ostream_iterator(std::cout, " "));
std::system("PAUSE >> void");
return 0;
}