Pagini recente » Cod sursa (job #1741275) | Cod sursa (job #2213387) | Cod sursa (job #576311) | Cod sursa (job #1032528) | Cod sursa (job #2333932)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("aria.in");
ofstream out("aria.out");
struct point{
double x, y;
}ext;
int n;
double arie = 0;
double det(point e, point a, point b){
return (a.x - e.x) * (b.y - e.y) - (b.x - e.x) * (a.y - e.y);
}
int main() {
ext.x = -1000007;
ext.y = -1000007;
in >> n;
point a, b;
point first;
in >> a.x >> a.y;
first = a;
for (int i = 0; i < n; ++i) {
in >> b.x >> b.y;
arie += (0.5 * det(ext, a, b));
a = b;
}
arie += (0.5 * det (ext, b, first));
out << arie;
return 0;
}