Cod sursa(job #2202954)
| Utilizator | Data | 10 mai 2018 15:58:23 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <cmath>
#include <iostream>
using namespace std;
ifstream fin("infasuratoare.in");
ofstream fout("infasuratoare.out");
typedef double ld;
struct point
{
ld x;
ld y;
};
ld trapez(point a,point b)
{
return (a.y+b.y)*(b.x-a.x);
}
const int N=100000;
int n;
point v[N+5];
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
v[n+1]=v[1];
ld arie=0;
for(int i=1;i<=n;i++)
arie+=trapez(v[i],v[i+1]);
fout<<fabs(0.5*arie);
return 0;
}
