Pagini recente » Cod sursa (job #2663949) | Cod sursa (job #854424) | Cod sursa (job #2977101) | Cod sursa (job #2526693) | Cod sursa (job #1798466)
#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 += abs(det(p1,p2,p3)) / 2.0;
p2 = p3;
}
f.close();
f.open("aria.out", ios::out);
f << s;
return 0;
}