Cod sursa(job #1486107)

Utilizator tim04Timo Timo tim04 Data 13 septembrie 2015 20:42:15
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 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;
}