Pagini recente » Cod sursa (job #2549346) | Cod sursa (job #2471137) | Cod sursa (job #2451065) | Cod sursa (job #1447312) | Cod sursa (job #1235807)
#include <cstdio>
#include <cmath>
#define eps 1.e-6
#define INF 1.e9
using namespace std;
class POINT
{
private:
double x,y;
public:
void set(double a,double b)
{
x=a;y=b;
}
double distanta(const POINT & other)
{
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
friend double aria(POINT & a,POINT & b,POINT & c)
{
double l1,l2,l3,p;
l1=a.distanta(b);l2=b.distanta(c);l3=c.distanta(a);
p=(l1+l2+l3)/2;
return sqrt(p*(p-l1)*(p-l2)*(p-l3));
}
};
POINT v[100005];
int main()
{
freopen("aria.in","r",stdin);
freopen("aria.out","w",stdout);
int n,i;
double a,b,s=0.0;
scanf("%d",&n);
for(i=1;i<=n;++i)
{
scanf("%lf%lf",&a,&b);
v[i].set(a,b);
}
for(i=3;i<=n;++i)
s+=aria(v[1],v[i-1],v[i]);
printf("%.5lf",s);
return 0;
}