Cod sursa(job #1486088)

Utilizator tim04Timo Timo tim04 Data 13 septembrie 2015 20:11:42
Problema Jocul Flip Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <stdio.h>
#include <fstream>
#include <iostream>
using namespace std;
int main() {
	int row , column;
	ifstream f;
	ofstream f1;
	f.open("flip.in",ifstream::in);
	f1.open("flip.out",ofstream::out);
	f >> row;
	f >> column;
	long matrix[row][column];
	int sum = 0;
	int sumInterm = 0;
	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++)
				{
					if(k == i || l == j)
					{
						matrix[k][l]*=-1;
					}
					sumInterm+=matrix[k][l];
				}
			}
			if( sumInterm > sum )
			{
				sum = sumInterm;
			}
			}
	}
	f1 << sum;
	f.close();
	return 0;
}