Cod sursa(job #3222614)

Utilizator MegaCoderMinoiu Teodor Mihai MegaCoder Data 11 aprilie 2024 09:16:33
Problema Aria Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include<fstream>
std::ifstream fin("aria.in");
std::ofstream fout("aria.out");
double getDet(double xa, double xb, double ya, double yb)
{
    return (double)(xa*yb-xb*ya);
}

int main()
{
    int n;
    double arie=0;
    fin>>n;
    double x0, y0, xprev, yprev, x1, y1;
    fin>>xprev>>yprev;
    x1=xprev, y1=yprev;
    for(int index=1; index<n; ++index)
    {
        fin>>x0>>y0;
        double localDet=getDet(xprev, x0, yprev, y0);
        arie+=localDet;
        xprev=x0;
        yprev=y0;
    }
    arie+=getDet(xprev, x1, yprev, y1);
    fout<<arie/2.0;
    return 0;
}