Cod sursa(job #1294338)

Utilizator killer301Ioan Andrei Nicolae killer301 Data 17 decembrie 2014 12:59:49
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include <cstdio>

using namespace std;

const int nmax = 100000;

struct point
{
	double x, y;
};

point a[nmax+5];

double ccw(point a, point b, point c)
{
	double cp = (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);
	return cp/2;
}

int main()
{
    freopen("aria.in", "r", stdin);
    freopen("aria.out", "w", stdout);
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
	{
		double x, y;
		scanf("%lf%lf", &x, &y);
		a[i].x = x; a[i].y = y;
	}
	double A = 0;
	for(int i=1; i<n-1; i++)
	{
		A+=ccw(a[0], a[i], a[i+1]);
	}
	printf("%.5lf", A);
    return 0;
}