Cod sursa(job #1268737)

Utilizator cipriancxFMI - gr143 Timofte Ciprian cipriancx Data 21 noiembrie 2014 13:13:27
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.54 kb
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int n;
double arie;

struct punct{double x;double y;}a,b,p;

double f(struct punct a, struct punct b)
{
    return 0.5 * ((a.x)*(b.y) - (b.x)*(a.y));
}
int main()
{
    freopen("aria.in","r",stdin);
    freopen("aria.out","w",stdout);


scanf("%d",&n);

scanf("%lf %lf",&a.x,&a.y);

p=a;
for(int i=2; i<=n; i++)
{
    scanf("%lf %lf",&b.x,&b.y);

    arie+=f(a,b);

    a=b;

}

    arie+=f(a,p);

   printf("%.10f",arie);
    return 0;
}