Control C401A

Your task is to write a program that reads a sequence of square matrices of integers, and for each one prints the sum of the numbers which are in their two diagonals.

Usign the definition

    typedef vector<vector<int> > Matrix;

your program must implement and use the function

    int sum_diagonals(const Matrix& mat);

that returns the sum of the numbers in the diagonals of the square matrix and non empty |mat|.

Input

The input consists of a sequence of cases. Each case starts with the size n1n \ge 1 of the matrix, followed by nn lines, each one with the nn integers of the corresponding row.

Output

For each matrix, print a line with the sum of the numbers which are in its diagonals.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:21:33.443Z

© Jutge.org, 2006–2026.
https://jutge.org