Pagini recente » Cod sursa (job #1679324) | Cod sursa (job #749460) | Cod sursa (job #2027919) | Cod sursa (job #1551678) | Cod sursa (job #1158882)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct Point
{ double x,y; } p[100005],pct;
double sol; int n;
double crossprod(Point a,Point b,Point c)
{ return (double) a.x*b.y+b.x*c.y+c.x*a.y-a.y*b.x-b.y*c.x-c.y*a.x; }
int main()
{ int i;
f>>n;
pct.x=pct.y=1000005;
for(i=1;i<=n;i++)
f>>p[i].x>>p[i].y;
n++; p[n]=p[1];
for(i=2;i<=n;i++)
sol+=crossprod(p[i-1],p[i],pct);
g<<fixed<<setprecision(5)<<fabs(sol/2);
return 0;
}