#K2586. Diagonal Difference
Diagonal Difference
Diagonal Difference
Given a square matrix, compute the absolute difference between the sums of its two diagonals. The primary diagonal is defined as (\sum_{i=0}^{n-1} a_{ii}) and the secondary diagonal is defined as (\sum_{i=0}^{n-1} a_{i, n-i-1}).
In each test case, you are provided with an integer (n) representing the size of the matrix, followed by (n) lines each containing (n) space-separated integers. For each test case, calculate and output the absolute diagonal difference.
inputFormat
The input starts with an integer (T), the number of test cases. Each test case begins with an integer (n) (the dimension of the matrix), followed by (n) lines with (n) space-separated integers each representing a row of the matrix.
outputFormat
For every test case, output a single integer on a new line representing the absolute difference between the sums of the matrix's primary and secondary diagonals.## sample
3
2
1 2
3 4
3
11 2 4
4 5 6
10 8 -12
3
1 2 3
4 5 6
7 8 9
0
15
0
</p>