Cod sursa(job #1974089)

Utilizator TataruTataru Mihai Tataru Data 26 aprilie 2017 19:32:31
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

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

int main()
{
    long double a = 0;
    double x1, x2, y1, y2;
    int N;
    fin >> N;
    fin >> x1 >> y1;
    double x = x1, y = y1;
    for(int i = 2; i <= N; i++)
    {
        fin >> x2 >> y2;
        a += x1 * y2 - x2 * y1;
        x1 = x2, y1 = y2;
    }
    a += x1 * y - x * y1;
    fout << fixed << setprecision(5) << a / 2;
    return 0;
}