Pagini recente » Cod sursa (job #787018) | Cod sursa (job #1403613) | Cod sursa (job #1105178) | Cod sursa (job #237722) | Cod sursa (job #2414733)
#include <cstdio>
using namespace std;
struct POINT
{
int x , y;
};
POINT P[100005];
double cp(POINT P1 , POINT P2 , POINT P3)
{
return (P2.x - P1.x) * (P3.y - P2.y) - (P2.y - P1.y) * (P3.x - P2.x);
}
int main()
{
freopen("aria.in" , "r" , stdin);
freopen("aria.out" , "w" , stdout);
int n , tx , ty , i;
double arie = 0;
scanf("%d" , &n);
for(i = 1 ; i <= n ; i ++)
{
scanf("%d%d" , &tx , &ty);
P[i].x = tx;
P[i].y = ty;
}
P[n + 1] = P[1];
for(i = 2 ; i <= n + 1 ; i ++)
arie = arie + cp(P[0] , P[i - 1] , P[i]);
printf("%.5lf\n" , arie * 0.5);
return 0;
}