#include
using namespace std;
int main()
{
int m,n;
cin>>m>>n;
int a[m][n];
int sum=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
for(int i=0;i<m;i++)
{
for(int j=1;j<n;j++)
{
a[i][j]+=a[i][j-1];
}
}
for(int j=0;j<n;j++)
{
for(int i=1;i<m;i++)
{
a[i][j]+=a[i-1][j];
}
}
for(int li=0;li<m;li++)
{
for(int lj=0;lj<n;lj++)
{
for(int bi=li;bi<m;bi++)
{
for(int bj=lj;bj<n;bj++)
{
sum+=a[bi][bj]-a[li-1][bj]-a[bi][lj-1]+a[li-1][lj-1];
}
}
}
}
cout<<sum<<endl;
return 0;
}
Where is the error in my code . please help me with the code
there is no link showing that can be copied to share here
go to this link -> https://ide.codingblocks.com/
paste ur code in the editor
press ctrl + s and then save
a link will be generated in ur search bar, share that link with me
i went on this link … opened it … copy pasted my code saved it … bt when i click on share option it only comes with three option email fb or twitter and there is no other link to share
for(int bj=lj;bj<n;bj++)
{
sum+=a[bi][bj]-a[li-1][bj]-a[bi][lj-1]+a[li-1][lj-1];
}
in this line u need to handle corner cases seprately
corner cases->
li==0 (li-1 will be -1 ) so handle it seprately
lj==0 (lj-1 will be -1) so handle it seprately
refer this->