Pagini recente » Cod sursa (job #2821530) | Cod sursa (job #494675) | Cod sursa (job #2452629) | Cod sursa (job #1119443) | Cod sursa (job #2449880)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct point
{
int 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++)
{
int x, y;
fin >> x >> y;
vp.push_back(point(x, y));
}
long double arie = 0;
int i, j;
for (i = 0; i < n-1; i++) // alegem P 0 0 pentru a scapa de calcule mari
arie += (long double) vp[i].x * vp[i + 1].y - vp[i + 1].x * vp[i].y;
arie -= (long double)vp[0].x * vp[n-1].y - vp[n-1].x * vp[0].y;
fout << arie / 2;
}