Cod sursa(job #969954)
Utilizator | Data | 5 iulie 2013 18:56:20 | |
---|---|---|---|
Problema | Aria | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.57 kb |
#include <fstream>
#include <iomanip>
struct Point
{
int x, y;
};
int main(void)
{
std::ifstream in("aria.in");
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);
std::ofstream out("aria.out");
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) / 2.0;
delete[] ptrP;
out << std::setprecision(5) << dAns;
out.close();
return 0;
}