Cod sursa(job #1800105)

Utilizator valiro21Valentin Rosca valiro21 Data 7 noiembrie 2016 12:52:42
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <fstream>

using namespace std;

double getArea (double lx, double ly, double x, double y) {
	//ly = translate (ly);
	//y = translate (y);

	double X = x - lx;
	return X * (ly + y) / 2;
}

int main () {
	int n;
	double x, y, lx, ly, x0, y0, a = 0, k;
	ifstream cin ("aria.in");
	ofstream cout ("aria.out");

	cin >> n;
	cin >> lx >> ly;
	x0 = lx; y0 = ly;
	for (int i = 1; i < n; i++) {
		cin >> x >> y;
		a += getArea (lx, ly, x, y);
		lx = x;
		ly = y;
	}
	a += getArea (lx, ly, x0, y0);
	cout << abs(a) << '\n';
	return 0;
}