Pagini recente » Cod sursa (job #446337) | Cod sursa (job #2113429) | Cod sursa (job #2691306) | Cod sursa (job #1040847) | Cod sursa (job #2531425)
#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;
sort ( v + 2 , v + n + 1, crt );
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;
}