Pagini recente » Cod sursa (job #2887805) | Cod sursa (job #227359) | Cod sursa (job #2209409) | Cod sursa (job #2881044) | Cod sursa (job #2929949)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct pct
{
long double x;
long double y;
}a[100005];
int n;
void cit()
{
f>>n;
for(int i=0;i<n;i++)
{
f>>a[i].x>>a[i].y;
}
}
int det(pct A, pct B)
{
int nr=A.x*B.y-A.y*B.x;
return nr;
}
long double det_trap(pct A, pct B, pct C)
{
int nr=A.x*B.y+B.x*C.y+C.x*A.y-B.y*C.x-C.y*A.x-A.y*B.x;
return nr;
}
long double modul(long double x)
{
if(x<0)
return ((-1)*x);
return x;
}
long double supr()
{
long double s=0;
for(int i=0;i<n-1;i++)
s+=0.5*det(a[i],a[i+1]);
s+=0.5*det(a[n-1],a[0]);
return modul(s);
}
void afis()
{
g<<fixed<<setprecision(6)<<supr();
}
int main()
{
cit();
afis();
return 0;
}