class SubMatrixSum private int arr private int private int public SubM

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class SubMatrixSum
{
private int[,] arr;
private int N = 4;
private int M = 4;
public SubMatrixSum(int[,] inputArr)
{
arr = inputArr;
}
public int[,] Fix()
{
int[,] fixedArr = new int[4, 4];
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++)
fixedArr[i,j] = minElements(i, j, arr);
return fixedArr;
}
private int minElements(int imax, int jmax, int[,] Arr)
{
int min = Arr[0, 0];
for (int i = 0; i <= imax; i++)
for (int j = 0; j <= jmax; j++)
if (min > Arr[i, j])
min = Arr[i, j];
return min;
}
}