using System;
class Program
{
static void Main() {
int[,] arr = {
{1, 2, 3, 5},
{4, 5, 6, 5},
{7, 8, 9, 5}
};
int rows = arr.GetLength(0);
int cols = arr.GetLength(1);
int sumRow, sumCol;
for (int i = 0; i < rows; i++){
sumRow = 0;
for (int j = 0; j < cols; j++){
sumRow = sumRow + arr[i, j];
}
Console.WriteLine("Sum of row: " + i + " = " + sumRow);
}
for (int i = 0; i < cols; i++){
sumCol = 0;
for(int j = 0; j < rows; j++){
sumCol = sumCol + arr[j, i];
}
Console.WriteLine("Sum of col: " + i + " = " + sumCol);
}
}
}
/*
run:
Sum of row: 0 = 11
Sum of row: 1 = 20
Sum of row: 2 = 29
Sum of col: 0 = 12
Sum of col: 1 = 15
Sum of col: 2 = 18
Sum of col: 3 = 15
*/