Cod sursa(job #969999)
Utilizator | Data | 5 iulie 2013 20:36:07 | |
---|---|---|---|
Problema | Aria | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
#include <fstream>
#include <cstdio>
#include <cmath>
struct Point
{
long double x, y;
};
int main(void)
{
std::ifstream in("aria.in");
freopen ("aria.out", "w", stdout);
int nV;
in >> nV;
Point *ptrP(new Point[nV + 1]);
for(int i(0); i < nV; i++)
in >> ptrP[i].x >> ptrP[i].y;
in.close();
double dAns(0.0);
ptrP[nV] = ptrP[0];
for(int i(0); i < nV; i++)
dAns += (ptrP[i].x * ptrP[i + 1].y - ptrP[i + 1].x * ptrP[i].y);
printf ("%lf", fabs (dAns / 2.0));
return 0;
}