Cod sursa(job #1801938)

Utilizator Diana22Diana Lucaci Diana22 Data 9 noiembrie 2016 18:34:24
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.69 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;
};
point points[100002];

double arie(point a, point b, point c) {
	return (double)(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;

	for (int i = 0; i < n; i++) {
		f >> points[i].x >> points[i].y;
	}
	points[n]= points[0];
	for (int i = 1; i < n; i++) {
		aria += arie(points[0], points[i], points[i + 1]);
	}
g << fixed << setprecision(5) << aria;
return 0;
}