Pagini recente » Cod sursa (job #1055916) | Cod sursa (job #2161775) | Cod sursa (job #2379030) | Cod sursa (job #2124738) | Cod sursa (job #1871118)
#include <iostream>
#include <cstdio>
#define MAXN 100100
using namespace std;
struct pct
{
double x, y;
pct (double _x = 0, double _y = 0)
{
x = _x;
y = _y;
}
};
int n;
double sol;
pct a[MAXN];
void citire()
{
scanf("%d", &n);
double x, y;
for (int i = 1; i <= n; i++)
{
scanf("%lf %lf", &x, &y);
a[i] = pct(x, y);
}
}
double signedProduct(pct e, pct f)
{
return 0.5 * (e.x * f.y - f.x * e.y);
}
void solve()
{
for (int i = 1; i < n; i++)
sol += signedProduct(a[i], a[i+1]);
sol += signedProduct(a[n], a[1]);
}
int main()
{
freopen("aria.in", "r", stdin);
freopen("aria.out", "w", stdout);
citire();
solve();
printf("%lf", sol);
return 0;
}