Pagini recente » Diferente pentru blog/viata-dupa-olimpiade-2 intre reviziile 9 si 10 | Cod sursa (job #1781892) | Cod sursa (job #1307128) | Monitorul de evaluare | Cod sursa (job #1214098)
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int main()
{
int n,m,i,j,c=0,c1=0,s;
int a[16][16];
f>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
f>>a[i][j];
c=c+a[i][j];
}
c1=c1+a[i][j];
if(c<0)
for(j=1;j<=m;j++)
a[i][j]=a[i][j]*-1;
else
if(c1<0)
for(i=1;i<=n;i++)
a[i][j]=a[i][j]*-1;
}
f.close();
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
s=s+a[i][j];
g<<s;
g.close();
return 0;
}