Pagini recente » Cod sursa (job #2257927) | Cod sursa (job #2987473) | Cod sursa (job #206797) | Cod sursa (job #580491) | Cod sursa (job #1559029)
#include<cstdio>
#include<algorithm>
#include<cmath>
#define eps 1.e-12
using namespace std;
struct sp
{
long double x,y;
} ve[100005];
long double ccw(sp a,sp b,sp c)
{
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
bool cmp(sp b,sp c)
{
if(ccw(ve[1],b,c)>=eps)
return 1;
return 0;
}
long double dist(sp p1,sp p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
long double arie(sp p1,sp p2,sp p3)
{
long double a,b,c,p;
a=dist(p1,p2);
b=dist(p2,p3);
c=dist(p1,p3);
p=(a+b+c)/2;
return sqrt(p)*sqrt(p-a)*sqrt(p-b)*sqrt(p-c);
}
int main()
{
freopen("aria.in","r",stdin);
freopen("aria.out","w",stdout);
int n,i,j;
long double sum=0,xp=0,yp=0;
double s2,x,y;
//punctul e originea:
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%lf%lf",&x,&y);
ve[i].x=x;
ve[i].y=y;
}
n++;
ve[n]=ve[1];
for(i=1; i<n; i++)
{
sum += (ve[i].x*ve[i+1].y-ve[i+1].x*ve[i].y);
}
s2=sum/2;
printf("%.5lf\n",s2);
return 0;
}