Input:
3
9 8 7
6 5 4
3 2 1
Output: 20
size = int(input('Enter size of matrix: '))
m = []
sum = 0
for _ in range(size):
m.append(list(map(int, input().split())))
for i in range(size):
for j in range(size):
if i != j and i + j != size - 1:
sum += m[i][j]
print(sum)
Comments
Leave a comment