the output depends on the innn.in file. It reads two numbers, which make up the grid size, then it reads that many entries into the grid, then does some magic.
Code:
#include <fstream>
#include <cmath>
using namespace std;
#define N 501
ifstream f("innn.in");
ofstream g("outtt.out");
int n, k, l=N, c=N;
int a[N][N], mx=-5000*N*N-1;
int main()
{
int i, j, s, ii, jj;
f>>n>>k;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
f>>a[i][j];
}
}
for(i=1;i<=n-k+1;i++)
{
for(j=1;j<=n-k+1;j++)
{
s=0;
for(jj=j;jj<=j+k-1;jj++)
{
for(ii=1;ii<=n;ii++)
{
s+=a[ii][jj];
}
}
for(ii=i;ii<=i+k-1;ii++)
{
for(jj=1;jj<j;jj++)
{
s+=a[ii][jj];
}
}
for(ii=i;ii<=i+k-1;ii++)
{
for(jj=j+k;jj<=n;jj++)
{
s+=a[ii][jj];
}
}
if(s>mx)
mx=s, l=i, c=j;
}
}
g<<mx<<' '<<l<<' '<<c<<'\n';
return 0;
}
This is a much more readable variant. Variable names are still cuck.