1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
# include <iostream>
# include <vector>
# include <algorithm>
# include <iterator>
constexpr auto ROWS = 4;
constexpr auto COLS = 5;
int main()
{
int pay[ROWS][COLS] = {{2, 4, 4, 6, 7}, {1, 2, 3, 4, 5} , {1, 2, 3, 4, 5}, {1, 2, 4, 5, 6}};
std::vector<int> vec{};
for (auto i = 0; i < ROWS; ++i)
{
vec.push_back(std::accumulate(std::begin(pay[i]), std::end(pay[i]), 0));
}
for (const auto& elem : vec)std::cout << elem << " ";
}
|