Pagini recente » Cod sursa (job #1450056) | Cod sursa (job #111376) | Cod sursa (job #1807810) | Monitorul de evaluare | Cod sursa (job #1834367)
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int area_tot;
int n;
struct point
{
int x, y;
};
point p[100];
int areat(point a, point b, point c)
{
a.x -= c.x; b.x -= c.x;
a.y -= c.y; b.y -= c.y;
//return fabs((double)(a.x * b.y - b.x * a.y) / 2);
return fabs((int)(a.x * b.y - b.x * a.y) / 2);
}
int area(int n, point p[])
{
double area_tot = 0;
for (int i = 2; i < n; i++)
area_tot += areat(p[1], p[i], p[i + 1]);
return area_tot;
}
int main()
{
fin >> n;
for(int i = 1; i <= n; i++)
fin >> p[i].x >> p[i].y;
area_tot = area(n, p);
//fout << fixed << setprecision(1) << fabs(area_tot) << '\n';
fout << fabs(area_tot) << '\n';
return 0;
}