Sum of Regional Maxes

I should divide a 2D array into square regions with a given parameter(d), find the maxes of each region and then their sum.
Can anyone help?
What is the actual problem?
if a matrix has 6 rows 11 columns and the d=4
i can find the 4x4 submatrix and their maxs but there are left some sub-matrixes to but not 4x4 size
ex :
-1 5 -5 -6 -10 -6 -1 -9 -2 -2 7
-9 -10 -2 3 9 -5 6 3 5 -10 -1
6 6 0 -10 1 7 7 -9 0 -8 -8
9 -5 -4 -7 3 -8 4 8 -7 -8 0
-7 -8 -4 -9 -3 -1 -1 -8 5 -7 9
-9 -2 -10 -9 -3 -5 1 -5 1 10 -1
True, a N*M matrix can be neatly divided into d*d submatrices only if both N and M are divisible by d. Furthermore, there are up to three types of non-d*d submatrices:
(N%d)*d, d*(M%d), and the corner's (N%d)*(M%d).

You must have a reason to do the summation and that reason should guide your decision about what to do with the "leftovers".
* You could simply omit the leftovers, but then some large values will not contribute to the sum.
* You could include maxes of those smaller matrices, increasing the overall sum.
* Something else.
can you help me with a c++ code for this?
Topic archived. No new replies allowed.