Pagini recente » Cod sursa (job #804010) | Cod sursa (job #2114749) | Cod sursa (job #329880) | Cod sursa (job #1755567) | Cod sursa (job #2515741)
#include <cstdio>
#include <cmath>
using namespace std;
struct POINT
{
double x,y;
};
double aria_tr_semn(POINT P1,POINT P2,POINT P3)
{
double arie;
arie=0.5*((P2.x-P1.x)*(P3.y-P2.y)-(P2.y-P1.y)*(P3.x-P2.x));
return arie;
}
int main()
{
freopen("aria.in","r",stdin);
freopen("aria.out","w",stdout);
int n,i;
double tempx,tempy,arie_poligon=0;
POINT P1,P2,P3;
scanf("%d",&n);
scanf("%lf%lf",&tempx,&tempy);
P1.x=tempx;
P1.y=tempy;
scanf("%lf%lf",&tempx,&tempy);
P2.x=tempx;
P2.y=tempy;
for(i=3;i<=n;i++)
{
scanf("%lf%lf",&tempx,&tempy);
P3.x=tempx;
P3.y=tempy;
arie_poligon=arie_poligon+aria_tr_semn(P1,P2,P3);
P2=P3;
}
arie_poligon=fabs(arie_poligon);
printf("%lf",arie_poligon);
return 0;
}