Cod sursa(job #2574570)

Utilizator mirceamaierean41Mircea Maierean mirceamaierean41 Data 5 martie 2020 23:55:13
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;

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

struct punct
{
	long double x, y;
};

punct p, f, ant;
int n;

long double rez;

inline long double arie(punct a, punct b)
{
	return a.x * b.y - a.y * b.x;
}

int main()
{
	fin >> n;
	fin >> f.x >> f.y;
	ant = f;
	for (int i = 1; i < n; ++i)
	{
		fin >> p.x >> p.y;
		rez += arie(ant, p);
		ant = p;
	}
	rez += arie(ant, f);
	rez /= 2.00000;
	fout << fixed << setprecision(6) << fabs(rez) << "\n";
	return 0;
}