Cod sursa(job #2087365)

Utilizator stefanchistefan chiper stefanchi Data 13 decembrie 2017 15:21:47
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.65 kb
#include <cstdio>
#define NMAX 100 010
using namespace std;
int n;

double arie(double x1, double y1, double x2, double y2)
{
    double sol = (x1*y2) - (y1*x2);
    return sol;
}
void read()
{
    double x1,y1,x2,y2;
    double x,y;
    double sol = 0;
    freopen("aria.in","r",stdin);
    freopen("aria.out","w",stdout);
    scanf("%d\n%lf %lf",&n,&x1,&y1);
    x=x1;
    y=y1;
    for(int i = 1 ; i< n ; i++)
    {
        scanf("%lf %lf",&x2,&y2);
        sol+=arie(x1,y1,x2,y2);
        x1 = x2;
        y1 = y2;
    }
    sol+=arie(x,y,x1,y1);
    printf("\n%.5lf",sol/2);
}


int main()
{
    read();
    return 0;
}