Cod sursa(job #1997658)

Utilizator savigunFeleaga Dragos-George savigun Data 4 iulie 2017 23:40:14
Problema Aria Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
using namespace std;

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

struct Point {
    double x, y;
};

int n;
double s;
Point v[100005];

double get_signed_area(Point a, Point b) {
    return a.x * b.y - b.x * a.y;
}

int main()
{
    in >> n;
    for (int i = 1; i <= n; ++i) {
        in >> v[i].x >> v[i].y;
    }

    v[n + 1] = v[1];

    for (int i = 1; i <= n; ++i) {
        s += (v[i].x * v[i + 1].y - v[i + 1].x * v[i].y);
    }

    out << setprecision(4) << fabs(s / 2.0);

    return 0;
}