Pagini recente » Cod sursa (job #1904037) | Cod sursa (job #1967531) | Cod sursa (job #417964) | Cod sursa (job #2857768) | Cod sursa (job #1776893)
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
ifstream f ("aria.in");
ofstream g ("aria.out");
pair <double, double> pct[1000010], l, k, q;
int n, i, j, m;
double ariaTotala;
double aria ( pair <double, double> a, pair <double,double> b, pair <double, double> c )
{
double ans;
ans = a.x * b.y + b.x * c.y + c.x * a.y - c.x * b.y - a.x *c.y - b.x * a.y;
ans = ans*1/2;
return ans;
}
int main ()
{
f>>n;
for (i=1; i<=n; i++)
{
f>>pct[i].x>>pct[i].y;
}
pct[n+1]=pct[1];
q.x=0;
q.y=0;
for (i=1; i<=n; i++)
{
l=pct[i];
k=pct[i+1];
ariaTotala = ariaTotala + aria( l, k, q );
}
if (ariaTotala<0)
{
ariaTotala*=-1;
}
g.precision(5);
g<<fixed<<ariaTotala;
return 0;
}