Pagini recente » Cod sursa (job #1745428) | Cod sursa (job #3157241) | Cod sursa (job #857486) | Cod sursa (job #2557299) | Cod sursa (job #1834392)
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
long double area_tot;
int n;
struct point
{
int x, y;
};
point p[100005];
long double areat(point a, point b, point c)
{
a.x -= c.x;
b.x -= c.x;
a.y -= c.y;
b.y -= c.y;
return ((long double)(a.x * b.y - b.x * a.y) / 2);
//return fabs((int)(a.x * b.y - b.x * a.y) / 2);
}
long double area(int n, point p[])
{
long double area_tot = 0;
for (int i = 2; i < n; i++)
area_tot += areat(p[1], p[i], p[i + 1]);
return fabs(area_tot);
}
int main()
{
fin >> n;
for(int i = 1; i <= n; i++)
fin >> p[i].x >> p[i].y;
area_tot = area(n, p);
fout << fixed << setprecision(6) << fabs(area_tot) << '\n';
//fout << fabs(area_tot) << '\n';
return 0;
}