Cod sursa(job #1994261)

Utilizator Neamtu_StefanStefan Neamtu Neamtu_Stefan Data 24 iunie 2017 15:03:51
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <fstream>
#include <iomanip>

using namespace std;

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

int main()
{
    int n;
    double x,y,x1,y1,x2,y2;
    long double arie=0;

    fin >> n;
    fin >> x1 >> y1;
    x=x1,y=y1;

    for (int i=1;i<n;i++)
    {
        fin >> x2 >> y2;
        arie+=(x1*y2-x2*y1);
        x1=x2,y1=y2;
    }
    arie+=(x1*y-x*y1);
    if (arie<0)arie=-arie;

    fout << fixed << setprecision(5) << arie/2;

    return 0;
}