Cod sursa(job #2333908)
| Utilizator | Data | 2 februarie 2019 09:30:42 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <cstdio>
using namespace std;
struct pct
{
double x,y;
}Pol[100005];
int n;
double A=0;
void citire()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lf %lf",&Pol[i].x,&Pol[i].y);
}
}
double trap(pct A,pct B)
{
return ((A.y+B.y)*(B.x-A.x))/2;
}
void arie()
{
for(int i=0;i<n-1;i++)
A+=trap(Pol[i],Pol[i+1]);
A+=trap(Pol[0],Pol[n-1]);
A=(A>0)?A:-A;
printf("%.5f",A);
}
int main()
{
freopen("aria.in","r",stdin);
freopen("aria.out","w",stdout);
citire();
arie();
return 0;
}
