Cod sursa(job #3291587)

Utilizator nata.03Pal-Serban Natalia nata.03 Data 5 aprilie 2025 10:03:01
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>

using namespace std;

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

struct Punct
{
    long double x, y;
};

long double n, s=0;

long double AriaPoligon(Punct a, Punct b)
{
    return ((a.x * b.y) - (a.y * b.x))/2;
}

int main()
{
    Punct a,b,first;
    f >> n;
    f >> a.x >> a.y;

    first=a;

    for (int i=2; i<=n; i++)
    {
        f >> b.x >> b.y;
        s+=AriaPoligon(a,b);
        a.x=b.x;
        a.y=b.y;
    }
    s+=AriaPoligon(b,first);
    g << fixed << setprecision(5) << s;
}