Cod sursa(job #2697426)

Utilizator alexisgaming1234Partac Alexis Matei alexisgaming1234 Data 18 ianuarie 2021 16:11:00
Problema Jocul Flip Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
int main() 
{
    int N, M, i, j, c;
    float s, v[100][100];
    fin>>N>>M;
    for( int i = 1; i <= N; i++){
        s = 0;
        for( int c = 1; c <= M; c++){
           fin>>v[i][c];
           s = s + v[i][c];
        }
        if(s < 0)
            for( int j = 1; j <= M; j++)
                v[i][j] = -(v[i][j]);
    }
    for( int c = 1; c <= M; c++){
        s = 0;
        for( int i = 1; i <= N; i++)
          s = s + v[i][c];
        if( s < 0)
           for(int j = 1; j <= N; j++)
               v[j][c] = -(v[j][c]);
    }
    s = 0;
    for( int i = 1; i <= N; i++)
        for( int c = 1; c <= M; c++)
          s = s + v[i][c];
    fout<<s;
    return 0;
}