Cod sursa(job #1687398)
| Utilizator | Data | 12 aprilie 2016 20:38:12 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int main()
{
long a[15][15];
int i,j,n,m,sl=0,sc=0,st=0;
f>>n>>m;
for(i=0;i<m;++i)
for(j=0;j<n;++j)
f>>a[i][j];
for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
{sl+=a[i][j];
if(sl<0)
a[i][j]=a[i][j]*(-1);}
}
for(j=0;j<n;++j)
{
for(i=0;i<m;++i)
{sc+=a[i][j];
if(sc<0)
a[i][j]=a[i][j]*(-1);}
}
st=sc+sl;
g<<st;
f.close();
g.close();
return 0;
}
