Pagini recente » Cod sursa (job #1197295) | Cod sursa (job #1887457) | Cod sursa (job #1823597) | Cod sursa (job #732404) | Cod sursa (job #1801723)
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
struct Point {long double x, y;};
inline long double det(Point p1, Point p2, Point p3)
{
return p1.x*p2.y - p3.x*p2.y + p2.x*p3.y - p1.x*p3.y + p3.x*p1.y - p1.y*p2.x;
}
int main()
{
fstream f("aria.in", ios::in);
int n, i;
long double s;
Point p1, p2, p3;
f >> n;
f >> p1.x >> p1.y;
f >> p2.x >> p2.y;
s = 0;
for(i = 2; i <= n-1; ++i)
{
f >> p3.x >> p3.y;
s += det(p1,p2,p3) / 2.0;
p2 = p3;
}
f.close();
f.open("aria.out", ios::out);
f << abs(s);
return 0;
}