Cod sursa(job #2449880)

Utilizator r00t_Roman Remus r00t_ Data 20 august 2019 22:44:45
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

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


struct point
{
	int 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++)
	{
		int x, y;
		fin >> x >> y;
		vp.push_back(point(x, y));
	}
	long double arie = 0;
	int i, j; 
	for (i = 0; i < n-1; 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;
	arie -= (long double)vp[0].x * vp[n-1].y - vp[n-1].x * vp[0].y;
	fout << arie / 2;


}