Cod sursa(job #2572354)

Utilizator Alex100Alexandru Mihai Alex100 Data 5 martie 2020 12:35:20
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.51 kb
#include <bits/stdc++.h>
#define MAX 100100
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct poz{
int x,y;};
poz v[MAX];
double aria;
double determ(poz a,poz b,poz c)
{
    return ((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/2;
}
int n;
int main()
{
    int i;
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>v[i].x>>v[i].y;
    }
    for(i=2;i<n;i++)
        aria+=determ(v[1],v[i],v[i+1]);
    fout<<setprecision(5)<<fixed;
    fout<<aria;
    return 0;
}