Cod sursa(job #2539943)

Utilizator cristina-criCristina cristina-cri Data 6 februarie 2020 15:55:17
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <fstream>
#include <cmath>
#include <iomanip>

using namespace std;

ifstream f("aria.in");
ofstream g("aria.out");

int n;
long double sum;

struct punct{
    long double x, y;
}pct[100003];

long double arieTrapez(punct A, punct B)
{
    return ((long double)(B.y+A.y)*(B.x-A.x));
}

int main()
{
    f>>n;
    for(int i=1; i<=n; i++)
        f>>pct[i].x>>pct[i].y;
    //pct[n+1]=pct[1];

    for(int i=1; i<n; i++)
    {
        sum=sum+(arieTrapez(pct[i], pct[i+1]));///2;
    }
    sum=sum+(arieTrapez(pct[n], pct[1]));
    sum/=2;
    g<<fixed<<setprecision(6)<<abs(sum);


    return 0;
}