#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[100][100]={0};
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
int sum=0;
for(int ti=0;ti<n;ti++)
{
for(int tj=0;tj<n;tj++)
{
for(int bi=ti+1;bi<n;bi++)
{
for(int bj=tj+1;bj<n;bj++)
{
for(int i=ti;i<=bi;i++)
{
for(int j=tj;j<=bj;tj++)
{
sum+=a[i][j];
}
}
}
}
}
}
cout<<sum;
}
can you check where is the error
in a 2x2 matrix the loop doesnt end
in a 1x! matrix the sum is 0