Answer to Question #265988 in Python for vijay

Question #265988

program to find sum of non-diagonal elements of matrix of MxM

Input: 
3
9 8 7
6 5 4
3 2 1

Output: 20




1
Expert's answer
2021-11-14T09:21:09-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS