A square parcel table contributes only its top-left to bottom-right diagonal. Task: Sum the main diagonal from top-left to bottom-right. Input format: A square matrix: n followed by n*n integers in row-major order. Output format: One integer: the diagonal sum. Constraints: 1 <= n <= 100; -10^6 <= entries <= 10^6 Edge rules: Apply the stated zero, tie, boundary, and ordering conventions exactly.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 100; -10^6 <= entries <= 10^6
Tags:
