$ Sum Of All Submatrices Of A Given Matrix Implementation - [C++]

why does this line no 8 and 9 do I cannot understand

Hi @Somith
Line no 8 computes value of tl (top left) which is a formula for obtaining number of ways to choose from top-left elements while in line 9 we compute number of ways to choose from bottom-right elements that is br (bottom right).

i am not getting the click in my mind on how the loops are executing ,i mean to say that what are the process that is taking place inside the loop i know it is giving for top left and bottom right

See in the two for loops we are calculating the number of time an element a[i][j] can be there in a sub matrix and then just multiplying the value of a[i][j] to its occurrence. And the occurrence for each element is computed by tlbr.
Suppose we have :
1 1 1
1 1 1
1 1 1
here when you try to find out how many sub matrices will be there where a[1][1] is present then it will be 16 and also by using tl
br you will get 16 only. So tl*br is used for calculating number of matrices in which a[i][j] is present.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.