#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <iterator>
int main()
{
const int N = 5;
std::array<int, N> matrix[N]{
{-1, -2, -3, -4, -5},
{-6, -7, -8, -9, -10},
{-11, -12, -13, -14, -15},
{-16, -17, -18, -19, -20},
{-21, -22, -23, -24, -25}
};
std::vector<int> vec;
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
if(j < i)
if(matrix[i][j] < 0)
vec.push_back(matrix[i][j]);
}
std::copy(vec.begin(), vec.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <iterator>
int main()
{
const int N = 5;
std::array<int, N> matrix[N]{
{-1, -2, -3, -4, -5},
{-6, -7, -8, -9, -10},
{-11, -12, -13, -14, -15},
{-16, -17, -18, -19, -20},
{-21, -22, -23, -24, -25}
};
std::vector<int> vec;
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
if(j < i)
{
if(matrix[i][j] < 0)
vec.push_back(matrix[i][j]);
}
}
}
std::copy(vec.begin(), vec.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
}