Cod sursa(job #2495968)

Utilizator VerestiucAndreiVerestiuc Andrei VerestiucAndrei Data 20 noiembrie 2019 08:19:40
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
int n,i,j;
struct hatz
{
    int x,y;
};
hatz p[100];
double area(hatz a, hatz b, hatz c) {
a.x -= c.x; b.x -= c.x;
a.y -= c.y; b.y -= c.y;
return fabs((double)(a.x * b.y - b.x * a.y) / 2);
}
int area(int n, hatz p[]) {
double area_tot = 0;
for (int i = 2; i < n; i++) {
area_tot += area(p[1], p[i], p[i+1]);
}
return area_tot;
}
int main()
{
    fin>>n;
    for (i=1; i<=n; i++)
    {
        fin>>p[i].x>>p[i].y;
    }
    fout<<area(n,p);
    return 0;
}