Pagini recente » Cod sursa (job #2729925) | Cod sursa (job #18625)
Cod sursa(job #18625)
#include<fstream.h>
int a[100][100],s,n,i,j,l1,l2,c1,c2,b[10],gasit1,gasit=0,c[10],k;
int main()
{
ifstream f("zone.in");
ofstream g("zone.out");
f>>n;
for(i=1;i<=9;i++)
f>>b[i];
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
f>>a[i][j];
l1=1;l2=2;c1=1;c2=2;
while(!gasit)
{
int t=0;
k=1;
for(i=1;i<=l1;i++)
for(j=1;j<=c1;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l1+1;i<=l2;i++)
for(j=1;j<=c1;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l2+1;i<=n;i++)
for(j=1;j<=c1;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=1;i<=l1;i++)
for(j=c1+1;j<=c2;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=1;i<=l1;i++)
for(j=c2+1;j<=n;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l1+1;i<=l2;i++)
for(j=c1+1;j<=n;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l1+1;i<=l2;i++)
for(j=c2+1;j<=n;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l2+1;i<=n;i++)
for(j=c1+1;j<=c2;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=l2+1;i<=n;i++)
for(j=c2+1;j<=n;j++)
s=s+a[i][j];
c[k]=s;
k++;
s=0;
for(i=1;i<=9;i++)
{
gasit=0;
for(j=1;j<=9;j++)
if(b[i]==c[i])
gasit1=1;
if(gasit1==0)
t++;
}
if(t==0)
{
gasit=1;
g<<l1<<" "<<l2<<" "<<c1<<" "<<c2;
}
l2++;
c1++;
c2++;
}
return 0;
}