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
| #include <iostream>
int main()
{
const size_t rows = 4;
const size_t cols = 8;
int matrix[rows][cols] =
{
{1, -2, 3, -4, 5, -6, 7, -8},
{8, -7, 6, -5, 4, -3, 2, -1},
{1, -3, 5, -7, 8, -6, 4, -2},
{8, -6, 4, -2, 1, -3, 5, -7}
};
int prod = 1;
for (size_t i = 0, j = cols - 1; i < rows && j < cols; ++i, --j)
if (matrix[i][j] > 0)
prod *= matrix[i][j];
std::cout << prod << std::endl;
return 0;
} |