Pagini recente » Cod sursa (job #1318536) | Cod sursa (job #1826185) | Cod sursa (job #3292359) | Cod sursa (job #2194762) | Cod sursa (job #3202014)
#include <bits/stdc++.h>
using namespace std;
#define INFILE "aria.in"
#define OUTFILE "aria.out"
struct Point {
double x, y;
Point() : x(0), y(0) {}
Point(int _x, int _y) : x(_x), y(_y) {}
};
double produsPuncte(Point &a, Point &b){
return (a.x * b.y - b.x * a.y);
}
void solve(){
int n; cin >> n;
vector<Point> v(n + 1);
for(int i = 0; i < n; ++i){
cin >> v[i].x >> v[i].y;
}
v[n].x = v[0].x, v[n].y = v[0].y;
double ans = 0;
for(int i = 0; i < n; ++i){
ans += produsPuncte(v[i], v[i + 1]);
}
ans /= 2;
if(ans < 0) ans = -ans;
cout << fixed << setprecision(5) << ans << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
freopen(INFILE, "r", stdin);
freopen(OUTFILE, "w", stdout);
cin.tie(0), cout.tie(0);
solve();
return 0;
}