Matrix Diagonal Sum

Medium · rating 1300 · Matrix

The first line has n. The next n lines each have n integers. Print the sum of both diagonals; if n is odd, the centre element (shared by both) is counted once.

Constraints: 1 ≤ n ≤ 1000

Related problems

Open Matrix Diagonal Sum in Code Arena →