Pagini recente » Cod sursa (job #451072) | Cod sursa (job #1164156) | Cod sursa (job #259899) | Cod sursa (job #2100342) | Cod sursa (job #2450161)
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct point
{
long double x, y;
point(int x, int y)
{
this->x = x;
this->y = y;
}
point()
{
x = 0;
y = 0;
}
};
int main()
{
int n;
vector<point> vp;
fin >> n;
for (int i = 0; i < n; i++)
{
long double x, y;
fin >> x >> y;
vp.push_back(point(x, y));
}
vp.push_back(vp[0]);
long double arie = 0;
int i;
for (i = 0; i < n; i++)
arie += (long double) (vp[i].x * vp[i + 1].y - vp[i + 1].x * vp[i].y)/2.00;
fout << fixed << setprecision(5) << fabs(arie);
}