Pagini recente » Cod sursa (job #2118812) | Cod sursa (job #7722) | Cod sursa (job #499224) | Cod sursa (job #2098884) | Cod sursa (job #1921154)
#include <bits/stdc++.h>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
#define point pair<double,double>
#define x first
#define y second
#define MAXN 100001
int N,i;
vector<point>v;
double arietr(point A, point B, point C)
{
return ((B.x-A.x)*(C.y-A.y) - (C.x-A.x) * (B.y-A.y)) /2 ;
}
double dist (point a,point b)
{
return sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
}
double ariaTriunghi(point a,point b,point c)
{
double ab=dist(a,b);
double ac=dist(a,c);
double bc=dist(b,c);
double p=(ab+ac+bc)/2;
return sqrt(p*(p-ab)*(p-ac)*(p-bc));
}
double ariaPoligon()
{
double S = 0;
for (int i = 2; i < N ; i++ )
S += arietr(v[1],v[i],v[i+1]);
//S += ariaTriunghi(v[1],v[i],v[i+1]);
return S;
}
int main()
{
f>>N;
v=vector<point>(N+1);
for(i=1;i<=N;i++)
f>>v[i].x>>v[i].y;
freopen("aria.out","w",stdout);
printf("%.6f ",ariaPoligon());
return 0;
}