Pagini recente » Cod sursa (job #959084) | Cod sursa (job #2128187) | Rating nicu loj (niculoj) | Cod sursa (job #1801453) | Cod sursa (job #805203)
Cod sursa(job #805203)
// infoarena.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#define MAX_WIDTH 500
#define MAX_HEIGHT 500
int Table[MAX_WIDTH][MAX_HEIGHT];
int N,M;
int s;
using namespace std;
int main()
{
ofstream out;
ifstream in;
in.open("flip.in");
out.open("flip.out");
if(in.is_open())
{
while(in.good())
{
in >> N;in>>M;
for(int i = 0; i < N; i++)
{
for(int j = 0; j < M; j++)
{
in >>Table[i][j];
//cout <<Table[N][M];
}
}
}
}
s = 0;
for(int i = 0; i < N; i++)
{
for(int j = 0; j < M; j++)
{
if(j < M)
{
if(Table[i][j] + Table[i][j+1] < -(Table[i][j] + Table[i][j+1]))
{
Table[i][j] = -Table[i][j];
}
}
s = s + Table[i][j];
}
}
out << s;
in.close();
out.close();
return 0;
}