Cod sursa(job #2301183)

Utilizator bogdi1bogdan bancuta bogdi1 Data 12 decembrie 2018 18:42:07
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.51 kb
#include <cstdio>
#include <cmath>
using namespace std;
const int eps = 1.e-14;
int main()
{   freopen("aria.in", "r",stdin);
    freopen("aria.out", "w",stdout);
    double x1,y1,x2,y2,a=0,x3,y3;
    int i,n;
    scanf("%d", &n);
    scanf("%lf%lf", &x1, &y1);
    x3=x1;
    y3=y1;
    for(i=2; i<=n;i++){
        scanf("%lf%lf", &x2, &y2);
        a+=(x1*y2)-(x2*y1);
        x1=x2;
        y1=y2;
    }
    a+=(x1*y3)-(x3*y1);
    a/=2.0;
    a=fabs(a);
    printf("%.6lf", a);
    return 0;
}