Pagini recente » Cod sursa (job #356895) | Cod sursa (job #3178771) | Cod sursa (job #2950629) | Cod sursa (job #224896) | Cod sursa (job #2128718)
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
const int NMAX = 100000 + 5;
struct point
{
double x;
double y;
point()
{
x = 0;
y = 0;
}
point(int _x, int _y)
{
x = _x;
y = _y;
}
};
point v[NMAX];
int n;
double area;
double get_area()
{
double sum = 0;
for (int i = 1; i <= n; ++i)
sum += v[i].x * v[i + 1].y - v[i + 1].x * v[i].y;
return sum / 2.0;
}
void write()
{
fout << setprecision(5) << fixed << area;
}
void read()
{
double x, y;
fin >> n;
for (int i = 1; i <= n; ++i)
{
fin >> x >> y;
v[i] = point(x, y);
}
v[n + 1] = v[1];
}
int main()
{
read();
area = get_area();
write();
return 0;
}