Cod sursa(job #1637219)

Utilizator hunchest4281Boca Bogdan hunchest4281 Data 7 martie 2016 15:55:17
Problema Jocul Flip Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
int main()
{
   int N, M, i, j, a[17][17], x=0, y=0;
   fin>>N>>M;
   for(i=1;i<=N;++i)
    for(j=1;j<=M;j++)
    fin>>a[i][j];
   for(i=1;i<=N;i++)
    for(j=1;j<=M;j++)
      {
      if (a[i][j]>0) x=x+a[i][j];
      else y=y+a[i][j];
      }
   if (x>(y*-1)) fout<<x;
   else {y=y*-1;
   fout<<y;}
   fin.close();
   fout.close();
   return 0;
}