#C1748. Diagonal Sums of a Square Matrix
Diagonal Sums of a Square Matrix
Diagonal Sums of a Square Matrix
Given a square matrix ( A ) of size ( n \times n ), compute the sum of its primary diagonal and secondary diagonal. The primary diagonal sum is given by ( \sum_{i=0}^{n-1} A_{i,i} ) and the secondary diagonal sum is given by ( \sum_{i=0}^{n-1} A_{i,n-1-i} ).
You are required to read the input from standard input (stdin) and output the results to standard output (stdout) as two integers separated by a space.
inputFormat
The first line contains an integer ( n ) denoting the size of the matrix. This is followed by ( n ) lines, each containing ( n ) space-separated integers representing the rows of the matrix.
outputFormat
Output two integers separated by a space: the sum of the primary diagonal and the sum of the secondary diagonal.## sample
3
1 2 3
4 5 6
7 8 9
15 15