Pagini recente » Cod sursa (job #28890) | Cod sursa (job #1786467) | Cod sursa (job #722114) | Cod sursa (job #2986413) | Cod sursa (job #1997652)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
using namespace std;
ifstream in("aria.in");
ofstream out("aria.out");
struct Point {
double x, y;
};
int n;
double s;
Point v[100005];
double get_signed_area(Point a, Point b) {
return a.x * b.y - b.x * a.y;
}
int main()
{
in >> n;
for (int i = 1; i <= n; ++i) {
double x, y;
in >> x >> y;
v[i] = {x, y};
}
v[n + 1] = v[1];
for (int i = 1; i <= n; ++i) {
s += get_signed_area(v[i], v[i + 1]);
}
double arie = s / 2;
out << setprecision(5) << fabs(arie);
return 0;
}