Pagini recente » Cod sursa (job #2227761) | Cod sursa (job #2861187) | Cod sursa (job #257553) | Cod sursa (job #2279932) | Cod sursa (job #2089069)
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
const int de = 100005;
struct point
{
double x, y;
};
double arie(point A, point B, point C) {
A.x -= C.x;
A.y -= C.y;
B.x -= C.x;
B.y -= C.y;
return ((A.x * B.y) - (A.y * B.x)) / 2;
}
double arie_cv(int n, point p[] ){
double tot = 0;
for( int i = 2 ; i < n ; ++i ){
tot += arie(p[1], p[i], p[i+1]);
}
return abs(tot);
}
int main(){
int n;
point p[de];
fin >> n;
for( int i = 1 ; i <= n ; ++i ){
fin >> p[i].x >> p[i].y;
}
fout << arie_cv(n, p);
return 0;
}