Pagini recente » Cod sursa (job #579581) | Cod sursa (job #1486086)
#include <stdio.h>
#include <fstream>
#include <iostream>
using namespace std;
int main() {
int row , column;
ifstream f;
ofstream f1;
f.open("file.in",ifstream::in);
f1.open("file.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;
}