Pagini recente » Cod sursa (job #3289330) | Istoria paginii utilizator/crownfurniture | Cod sursa (job #2697804) | Istoria paginii runda/siruri | Cod sursa (job #1801767)
/*#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
*/
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
struct point {
double x, y;
};
bool ccw(point a, point b, point c) {
return (a.x * b.y + b.x * c.y + a.y*c.x - a.x * c.y - a.y *b.x - c.x*b.y) > 0;//ccw
}
double arie(point a, point b, point c) {
return 0.5 * abs(a.x * b.y + b.x * c.y + a.y * c.x - a.x * c.y - a.y *b.x - c.x*b.y);
}
int main()
{
//freopen("aria.in", "r", stdin);
//freopen("aria.out", "w", stdout);
ifstream f("aria.in");
ofstream g("aria.out");
int n;
double aria = 0;
f >> n;
point points[100001];
for (int i = 0; i < n; i++) {
f >> points[i].x >> points[i].y;
}
for (int i = 1; i < n - 1; i++) {
double aux = arie(points[0], points[i], points[i + 1]);
if (ccw(points[0], points[i], points[i + 1])) {
aria += aux;
}
else {
aria -= aux;
}
}
g << fixed<<setprecision(5)<<aria;
return 0;
}