Cod sursa(job #948631)

Utilizator matei_cChristescu Matei matei_c Data 11 mai 2013 12:13:28
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include<fstream>
#include<iomanip>
using namespace std ;

ifstream fin("aria.in");
ofstream fout("aria.out");

#define maxn 100001

struct punct
{
    double x, y ;
};

int n ;

punct v[maxn] ;

int main()
{
    fin >> n ;

    for(int i = 1; i <= n; ++i )
        fin >> v[i].x >> v[i].y ;

    v[ n + 1 ] = v[1] ;

    double arie = 0 ;

    for(int i = 1; i <= n; ++i )
        arie += ( v[i].x * v[ i + 1 ].y - v[i].y * v[ i + 1 ].x ) ;

    arie /= 2.0 ;

    fout << setprecision(5) << fixed ;

    fout << arie ;

    return 0 ;
}