Objective
In a square matrix, the main diagonal runs from top left to bottom right (m[i][i]) and the secondary one from top right to bottom left (m[i][n-1-i]).
Instructions
- The first line has the size
nof the square matrix; then comenrows withnintegers. - Show
Main: xandSecondary: ywith the sum of each diagonal.
3
1 2 3
4 5 6
7 8 9
Main: 15
Secondary: 15
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise