Cod sursa(job #1268728)

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

int n;
long double arie;

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

long 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);
cin>>a.x>>a.y;
p=a;
for(int i=2; i<=n; i++)
{
    //scanf("%Lf %Lf",&b.x,&b.y);
cin>>b.x>>b.y;
    arie+=f(a,b);

    a=b;

}

    arie+=f(a,p);
cout<<arie;
   //printf("%Lf",arie);
    return 0;
}