Pagini recente » Cod sursa (job #229985) | Cod sursa (job #2499487) | Cod sursa (job #2389093) | Cod sursa (job #2601080) | Cod sursa (job #1997648)
#include <iostream>
#include <fstream>
#include <iomanip>
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) << arie;
return 0;
}