Pagini recente » Cod sursa (job #2305949) | Cod sursa (job #1115145) | Cod sursa (job #509197) | Cod sursa (job #2288916) | Cod sursa (job #969956)
Cod sursa(job #969956)
#include <fstream>
#include <iomanip>
#include <cmath>
struct Point
{
double 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::fabs(dAns);
out.close();
return 0;
}