Pagini recente » Cod sursa (job #1440559) | Cod sursa (job #1751560) | Cod sursa (job #1263970) | Cod sursa (job #2858926) | Cod sursa (job #2628211)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int main()
{
int n,m,i,x,y,w,M[100][16],suma,maxx,h,v[1600],p,j;
f>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
f>>M[i][j];
}
}
w=n*m;
for(h=1;h<=w;h++)
{
v[h]=0;
suma=0;
p=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
for(x=1;x<=n;x++)
{
for(y=1;y<=m;y++)
{
if(i!=x && j!=y)
{
v[h]=v[h]+M[x][y];
}
else
{
p=M[x][y];
p = p * (-1);
suma=suma+p;
}
}
}
v[h]=v[h]+suma;
}
}
}
maxx=0;
for(h=1;h<=w;h++)
{
if(v[h]>maxx)
{
maxx=v[h];
}
}
g<<maxx;
return 0;
}