Pagini recente » Cod sursa (job #2773469) | Profil Stefan_Raluca_Ioana | Cod sursa (job #2763952) | Cod sursa (job #461570) | Cod sursa (job #2697428)
/******************************************************************************
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( i = 1; i <= N; i++){
s = 0;
for( c = 1; c <= M; c++){
fin>>v[i][c];
s = s + v[i][c];
}
if(s < 0)
for( j = 1; j <= M; j++)
v[i][j] = -(v[i][j]);
}
for( c = 1; c <= M; c++){
s = 0;
for( i = 1; i <= N; i++)
s = s + v[i][c];
if( s < 0)
for( j = 1; j <= N; j++)
v[j][c] = -(v[j][c]);
}
s = 0;
for( i = 1; i <= N; i++)
for( c = 1; c <= M; c++)
s = s + v[i][c];
fout<<s;
return 0;
}