Cod sursa(job #2122555)

Utilizator ZenoTeodor Anitoaei Zeno Data 5 februarie 2018 11:33:00
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include <bits/stdc++.h>
#define NMAX 100001

using namespace std;

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

struct point{
    double x, y;
};

int n;
point O, A, B;
double aria;

double det(point A, point B, point C) {
    return (A.x * B.y + B.x * C.y + C.x * A.y - B.y * C.x - C.y * A.x - A.y * B.x) / 2;
}

int main()
{
    fin >> n;
    O.x = O.y = 0;
    fin >> A.x >> A.y;
    for(int i = 2; i <= n; i++) {
        fin >> B.x >> B.y;
        aria += det(O, A, B);
        A = B;
    }
    fout << fixed;
    fout << setprecision(5) << aria << '\n';
    return 0;
}