Cod sursa(job #1801923)

Utilizator Diana22Diana Lucaci Diana22 Data 9 noiembrie 2016 18:25:56
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.03 kb
/*#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
*/
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
struct point {
	double x, y;
};
bool ccw(point a, point b, point c) {
	return (a.x * b.y + b.x * c.y + a.y*c.x - a.x * c.y - a.y *b.x - c.x*b.y) > 0;//ccw
}

double arie(point a, point b, point c) {
	return (double)abs(a.x * b.y + b.x * c.y + a.y * c.x - a.x * c.y - a.y *b.x - c.x*b.y)/2.0;
}
int main()
{
	ifstream f("aria.in");
	ofstream g("aria.out");

	int n;
	double aria = 0;
	f >> n;
	point points[100001];
	for (int i = 0; i < n; i++) {
		f >> points[i].x >> points[i].y;
	}
	/*for (int i = 1; i < n - 1; i++) {
		double aux = arie(points[0], points[i], points[i + 1]);
		if (ccw(points[0], points[i], points[i + 1])) {
			aria += aux;
		}
		else {
			aria -= aux;
		}
	}*/
	for (int i = 0; i < n; i++) {
		aria += (points[i].x * points[i + 1].y - points[i + 1].x * points[i].y);
	}
	aria /= 2.0;
	g << fixed<<setprecision(5)<<aria;
	return 0;
}