Cod sursa(job #2549972)

Utilizator Briana_NeaguNeagu Briana Briana_Neagu Data 18 februarie 2020 10:13:47
Problema Aria Scor 100
Compilator cpp-32 Status done
Runda Arhiva educationala Marime 0.61 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("aria.in");
ofstream g("aria.out");

struct point
{
    long double x;
    long double y;
};

long double findDet(point a, point b, point c)
{
    return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

int main()
{
   int n;
   f >> n;
   vector <point> allPoints(n + 1);
   for (int i = 1; i <= n; ++ i)
       f >> allPoints[i].x >> allPoints[i].y;
   point setPoint = allPoints[1];
   long double sum = 0;
   for (int i = 1;  i < n; ++ i)
       sum += findDet(setPoint, allPoints[i], allPoints[i + 1]);
   g << setprecision(6) << fixed << sum / 2.00;
}