Pagini recente » Cod sursa (job #67984) | Cod sursa (job #2582709) | Cod sursa (job #1598439) | Cod sursa (job #1055411) | Cod sursa (job #2749093)
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Point
{
double x, y;
Point(double x, double y)
{
this->x = x;
this->y = y;
};
};
int N;
vector<Point> points;
void read()
{
fin >> N;
for(int i = 0; i < N; ++i)
{
double x, y;
fin >> x >> y;
points.emplace_back(x, y);
}
}
void solve()
{
double solution = 0;
points.emplace_back(points[0].x, points[0].y);
for(int i = 0; i < N; ++i)
{
solution += (points[i].x * points[i + 1].y - points[i + 1].x * points[i].y);
}
fout << fixed << setprecision(5) << fabs(solution / 2.0);
}
int main()
{
read();
solve();
return 0;
}