Cod sursa(job #2450159)

Utilizator r00t_Roman Remus r00t_ Data 22 august 2019 10:22:17
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.74 kb
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
#include <iomanip>

using namespace std;

ifstream fin("aria.in");
ofstream fout("aria.out");


struct point
{
	long double x, y;
	point(int x, int y)
	{
		this->x = x;
		this->y = y;
	}
	point()
	{
		x = 0;
		y = 0;
	}
};

int main()
{
	int n;
	vector<point> vp;
	fin >> n;
	for (int i = 0; i < n; i++)
	{
		long double x, y;
		fin >> x >> y;
		vp.push_back(point(x, y));
	}
	vp.push_back(vp[0]);

	long double arie = 0;
	int i; 
	for (i = 0; i < n; i++) // alegem P 0 0 pentru a scapa de calcule mari
		arie += (long double) vp[i].x * vp[i + 1].y - vp[i + 1].x * vp[i].y;
	fout << fixed << setprecision(5) << fabs(arie / 2);


}