Pagini recente » Cod sursa (job #2509362) | Cod sursa (job #3185155) | Cod sursa (job #1012931) | Clasament FMI No Stress 2012 | Cod sursa (job #2535738)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
struct Punct
{
long double x, y;
}v[100005];
bool crt ( Punct a, Punct b );
long double ariaTriunghiului ( Punct a, Punct b, Punct c )
{
b.x =b.x- a.x;
b.y =b.y- a.y;
c.x =c.x- a.x;
c.y =c.y- a.y;
a.x = a.y = 0;
return ( b.x * c.y - b.y * c.x ) / 2;
}
int main()
{
int n, i;
long double aria = 0;
fin >> n;
for ( i = 1 ; i <= n ; i++ ) fin >> v[i].x >> v[i].y;
for ( i = 2 ; i < n ; i++ ) aria =aria+ ariaTriunghiului ( v[1], v[i], v[i+1] );
fout << setprecision ( 5 ) << fixed << aria;
return 0;
}