Pagini recente » Cod sursa (job #2709281) | Cod sursa (job #918281) | Cod sursa (job #153203) | Cod sursa (job #2650933) | Cod sursa (job #2531447)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
struct Punct
{
long double x, y;
};
Punct v[100005];
bool crt ( Punct a, Punct b );
long double aria_triunghi ( Punct a, Punct b, Punct c );
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_triunghi ( v[1], v[i], v[i+1] );
fout << setprecision ( 5 ) << fixed << aria;
return 0;
}
bool crt ( Punct a, Punct b )
{
if ( aria_triunghi ( v[1], a, b ) > 0 ) return 1;
return 0;
}
long double aria_triunghi ( Punct a, Punct b, Punct c )
{
b.x -= a.x;
b.y -= a.y;
c.x -= a.x;
c.y -= a.y;
a.x = a.y = 0;
return ( b.x * c.y - b.y * c.x ) / 2;
}