Cod sursa(job #1795572)
Utilizator | Data | 2 noiembrie 2016 17:46:53 | |
---|---|---|---|
Problema | Aria | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
struct pct{
double x, y;
};
int n;
double A;
pct p[100005];
double det( pct a, pct b, pct c);
int main()
{
int i;
fin>>n;
for(i=1; i<=n; ++i)
fin>>p[i].x>>p[i].y;
for(i=3; i<=n; ++i)
A=A+det(p[1], p[i-1], p[i]);
fout<<A<<'\n';
return 0;
}
double det( pct a, pct b, pct c)
{
return ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))/2;
}