Cod sursa(job #1023811)

Utilizator timicsIoana Tamas timics Data 7 noiembrie 2013 19:28:39
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include<stdio.h>
#include<iostream>
using namespace std;

long double x[2],y[2],a,b,S;
int N;

int main()
{
    freopen("aria.in","r",stdin);
    freopen("aria.out","w",stdout);
    scanf("%d",&N);
    for(int i=1;i<=N;++i)
    {
        cin>>x[0]>>y[0];

        if(i==1)
        {
            a = x[0];
            b = y[0];
        }

        else
        {
            S = S + x[1]*y[0] - x[0]*y[1];
        }

        x[1] = x[0];
        y[1] = y[0];

    }

    S = S + b*x[1] - a*y[1];

    if(S<0)
        cout<<-S/2;
    else
        cout<<S/2;
    return 0;
}