I don't know if this is what you think, but i found a solution ! You have to enter that
number or "addition" and them enter length and height of matrix and max-length
and max-height of sub-matrix and then whole matrix ! After that you will get solution
or better said number of sub-matrix !
Code:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout<<"- - - - - - - - - - - - - - - - - - -\n";
cout<<" Program for finding sub matrix with\n";
cout<<" entered addition by Dr DEBCOL !\n";
cout<<"- - - - - - - - - - - - - - - - - - -\n";
int i,j,n,f,t,r,e;
cout<<"Enter addition !\n";
cin>>t; //ADDITION
cout<<"Enter length of matrix ?\n";
cin>>n; //N IS LENGTH
cout<<"Enter height of matrix ?\n";
cin>>f; //F IS HEIGHT
cout<<"Enter maximum length of sub-matrix ?\n";
cin>>r; //R IS LENGTH OF SUB-MATRIX
cout<<"Enter maximum height of sub-matrix ?\n";
cin>>e; //E IS HEIGHT OF SUB-MATRIX
cout<<"Enter array with parts separated with space !\n";
cout<<"After you finish one line press Enter to type another !\n";
int a[n][f];
for (i=1;i<=n;i++)
for (j=1;j<=f;j++)
cin>>a[i][j];
int i1,j1,i2,j2,s,k;
s=0;
k=0;
for (i1=1;i1<=n;i1++)
for (j1=1;j1<=f;j1++)
{
s=0;
for (i2=i1;i2<=(r+i1);i2++)
for (j2=j1;j2<=(e+j1);j2++)
{
s+=a[i2][j2];
if (s==t)
{
k++;
s=0;
}
}
}
cout<<"Number of sub matrix with "<<t<<" addition is "<<k<<" ! \n";
cin.get();
cin.get();
}
Visit this programming forum : http://www.syntax-e.co.cc/