Pagini recente » Cod sursa (job #991599) | Cod sursa (job #438881) | Cod sursa (job #1350434) | Cod sursa (job #2274937) | Cod sursa (job #1486107)
#include <stdio.h>
#include <fstream>
#include <iostream>
using namespace std;
int row , column, sum = 0, sumInterm = 0, nr, matrix[16][16];
int main() {
ifstream f;
ofstream f1;
f.open("flip.in",ifstream::in);
f1.open("flip.out",ofstream::out);
f >> row;
f >> column;
for(int i=0; i<row; i++)
{
for(int j=0; j<column; j++)
{
f >> matrix[i][j];
}
}
for(int i=0; i<row; i++)
{
for(int j=0; j<column; j++)
{
sumInterm = 0;
for(int k=0; k<row; k++)
{
for(int l=0; l<column; l++)
{
nr = matrix[k][l];
if(k == i || l == j)
{
nr*=-1;
}
sumInterm+=nr;
}
}
if( sumInterm > sum )
{
sum = sumInterm;
}
}
}
f1 << sum;
f.close();
f1.close();
return 0;
}