Cod sursa(job #2720787)

Utilizator dimi999Dimitriu Andrei dimi999 Data 11 martie 2021 11:54:14
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>
using namespace std;

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

struct Points
{
    int x, y;
};

vector <Points> p;

int main()
{
    int N;

    fin >> N;

    for(int i = 1; i <= N; i++)
    {
        int x, y;

        fin >> x >> y;

        p.push_back({x, y});
    }

    p.push_back(p[0]);

    double A = 0;

    for(int i = 0; i < N; i++)
        A += (double)(p[i].x * p[i + 1].y - p[i + 1].x * p[i].y);

    fout << fixed << setprecision(6) << A / 2;

    return 0;
}