Cod sursa(job #2203052)

Utilizator Alex_BubBuburuzan Alexandru Alex_Bub Data 10 mai 2018 20:04:37
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>

using namespace std;

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

const int NMAX = 100000;

struct st{int x, y;} v[NMAX + 5];

int main()
{
    int n;

    float s = 0;

    fin >> n;

    for(int i = 1; i <= n; i++)
        fin >> v[i].x >> v[i].y;

    v[n + 1].x = v[1].x;
    v[n + 1].y = v[1].y;

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

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

    fin.close();
    fout.close();

    return 0;
}