Diagonal sum
Submissions: 2869   Accuracy:

31.12%

  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

Given a square matrix of size M×M. Your task is to calculate the sum of its diagonals.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. First line of each test case contains a single integer M denoting the size of the square matrix. The next  line contains M*M space separated values of the matrix A.

Output:
For each test case in a new line print the sum of diagonals of the matrix.

Constraints:
1  ≤  T  ≤  20
2  ≤  M  ≤  10
1  ≤  A[i]  ≤  20

Example:
Input:
1
3
1 1 1 1 1 1 1 1 1

Output:
6

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: karan kumar
Author: karanshrm44


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.