Compute sum of all elements , sum of every row and sum every column
for i in range ( 0 , R ) : NEW_LINE INDENT for j in range ( 0 , C ) : NEW_LINE INDENT Sum += mat [ i ] [ j ] NEW_LINE row [ i ] += mat [ i ] [ j ] NEW_LINE col [ j ] += mat [ i ] [ j ] NEW_LINE DEDENT DEDENT