Pagini recente » Cod sursa (job #2060131) | Borderou de evaluare (job #2537422) | Cod sursa (job #2722909)
#include <bits/stdc++.h>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
// #define f cin
// #define g cout
// code-runner.runInTerminal
#define double long double
struct point
{
double x, y;
friend istream &operator>>(istream &is, point &t)
{
is >> t.x >> t.y;
return is;
}
point operator-(const point &t) const
{
point rez = {x - t.x, y - t.y};
return rez;
}
double operator*(const point &t) const
{
double ar = (double)x * t.y - (double)y * t.x;
return ar;
}
double arrel(const point &a, const point &b) const
{
return (a - *this) * (b - *this);
}
};
int main()
{
int n;
f >> n;
vector<point> v(n);
for (auto &i : v)
f >> i;
double rez = 0;
for (size_t i = 0; i < v.size(); i++)
{
size_t j = (i + 1) % v.size();
rez += v[i] * v[j];
}
rez = (double)rez / 2.0;
rez = abs(rez);
g << fixed << setprecision(5) << rez;
return 0;
}