Pagini recente » Cod sursa (job #2326736) | Cod sursa (job #2188593) | Cod sursa (job #1846161) | Cod sursa (job #57128) | Cod sursa (job #2060313)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream in ("aria.in");
ofstream out ("aria.out");
int const nmax = 100000;
struct point{
long double x;
long double y;
};
long double det3(point a , point b ,point c){
long double splus = a.x * b.y + a.y * c.x + b.x * c.y;
long double sminus = a.x * c.y + a.y * b.x + b.y * c.x;
return (splus - sminus) * 0.5;
}
int main()
{
int n ;
in>>n;
point last ,p ,first ,a;
in>>first.x>>first.y;
last = first;
p.x = p.y = 0;
long double sum = 0;
for(int i = 2 ; i <= n ;i++){
in>>a.x>>a.y;
sum += det3(p , last , a);
last = a;
}
sum += det3(p , last , first);
out<<setprecision(6)<<fixed<<sum;
return 0;
}