Pagini recente » Cod sursa (job #321306) | Cod sursa (job #2246018) | Cod sursa (job #247733) | Cod sursa (job #1483709) | Cod sursa (job #2531436)
#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 + 1 , v + n + 1, crt );
v[n+1] = v[1];
for ( i = 1 ; i <= n ; i++ ) aria += aria_triunghi ( v[0], v[i], v[i+1] );
fout << setprecision ( 5 ) << fixed << aria;
return 0;
}
bool crt ( Punct a, Punct b )
{
if ( aria_triunghi ( v[0], 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;
}