Cod sursa(job #1225814)

Utilizator SteveStefan Eniceicu Steve Data 3 septembrie 2014 17:43:42
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <fstream>
#include <iomanip>
using namespace std;

int main ()
{
    int N;
    long double x1, x2, y1, y2, x0, y0, Aria = 0;
    ifstream fin ("aria.in");
    ofstream fout ("aria.out");
    fin >> N;
    fin >> x1 >> y1;
    x0 = x1;
    y0 = y1;
    for (int i = 1; i < N; i++)
    {
        fin >> x2 >> y2;
        Aria += x1 * y2 - x2 * y1;
        x1 = x2;
        y1 = y2;
    }
    Aria += x1 * y0 - x0 * y1;
    if (Aria < 0) Aria = -Aria;
    fout << fixed << setprecision (6) << Aria * 0.5;
    fin.close ();
    fout.close ();
    return 0;
}