Pagini recente » Cod sursa (job #2797065) | Cod sursa (job #1891317) | Cod sursa (job #1413705) | Cod sursa (job #2256245) | Cod sursa (job #3271090)
#include <float.h>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Point {
long double x, y;
};
int n;
vector<Point> points;
void read() {
fin >> n;
long double x, y;
for (int i = 1; i <= n; ++i) {
fin >> x >> y;
points.emplace_back(x, y);
}
points.push_back(points[0]);
}
long double modul(long double x) {
return x > 0.0 ? x : -x;
}
void solve() {
long double aria = 0;
for (int i = 0; i < points.size() - 1; ++i) {
aria += points[i].x * points[i + 1].y - points[i + 1].x * points[i].y;
}
fout << fixed << modul(aria) / 2.0;
}
int main() {
read();
solve();
return 0;
}