Pagini recente » Cod sursa (job #2212583) | Cod sursa (job #2168182) | Cod sursa (job #819159) | Cod sursa (job #1476792) | Cod sursa (job #2525712)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int n;
long double ans;
int x;
struct points
{
long double x;
long double y;
};
points v[100001];
long double aria(points a,points b,points c)
{
a.x-=c.x;
a.y-=c.y;
b.x-=c.x;
b.y-=c.y;
return (a.x*b.y-a.y*b.x)/2;
}
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0);
fout.tie(0);
fin>>n;
for(int i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
for(int i=1;i<=n-2;i++)
ans+=aria(v[1],v[i+1],v[i+2]);
fout<<fixed<<setprecision(6)<<ans;
return 0;
}