def calculateSum(matrix, r, c):
upperSum = 0
lowerSum = 0
for i in range(r):
for j in range(c-1,0,-1):
if (i >= j):
upperSum += matrix[i][j]
print(upperSum);
counter=0
# to calculate sum of lower
for i in range(r-1,-1,-1):
for j in range(counter,c):
lowerSum += matrix[i][j]
counter+=1
print(lowerSum)
R = int(input())
C = int(input())
matrix = []
for i in range(R):
arr = [int(i) for i in input().split()]
matrix.append(arr)
calculateSum(matrix, R, C)
Comments
Leave a comment