Pagini recente » Cod sursa (job #569053) | Cod sursa (job #617508) | Cod sursa (job #1964805) | Cod sursa (job #3156471) | Cod sursa (job #2749091)
#include <fstream>
#include <vector>
#include <cmath>
#include <iomanip>
#define infile "aria.in"
#define outfile "aria.out"
struct point {
double x, y;
point(double x, double y) : x(x), y(y) {}
};
std::ifstream f(infile);
std::ofstream g(outfile);
std::vector<point> v;
int n, i;
int main()
{
f >> n;
for (i = 0; i < n; ++i)
{
double x, y;
f >> x >> y;
v.emplace_back(x, y);
}
double sol = 0;
v.emplace_back(v[0].x, v[0].y);
for (i = 0; i < n; ++i)
{
sol += (v[i].x * v[i + 1].y - v[i + 1].x * v[i].y);
}
g << std::fixed << std::setprecision(5) << fabs(sol / 2.0);
return 0;
}