Pagini recente » Cod sursa (job #1560194) | Cod sursa (job #522198) | Cod sursa (job #719362) | Cod sursa (job #2194343) | Cod sursa (job #1834383)
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
double area_tot;
int n;
struct point
{
int x, y;
};
point p[100005];
int areat(point a, point b, point c)
{
a.x -= c.x; b.x -= c.x;
a.y -= c.y; b.y -= c.y;
return fabs((double)(a.x * b.y - b.x * a.y) / 2);
//return fabs((int)(a.x * b.y - b.x * a.y) / 2);
}
double area(int n, point p[])
{
double area_tot = 0;
for (int i = 2; i < n; i++)
area_tot += areat(p[1], p[i], p[i + 1]);
return 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(5) << abs(area_tot) << '\n';
return 0;
}