Cod sursa(job #2088737)
| Utilizator | Data | 15 decembrie 2017 19:36:32 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct point
{
int x, y;
};
double area(point a, point b, point c)
{
a.x-=c.x, a.y-=c.y;
b.x-=c.x, b.y-=c.y;
return fabs((double)(a.x*b.y-a.y*b.x)/2);
}
long double arie;
int n, i, j;
int main()
{
fin>>n;
point a;
fin>>a.x>>a.y;
point b;
fin>>b.x>>b.y;
point c;
for(i=3;i<=n;i++)
{
fin>>c.x>>c.y;
arie+=area(a,b,c);
b.x=c.x,b.y=c.y;
}
fout<<arie;
return 0;
}
