Pagini recente » Cod sursa (job #2495475) | Cod sursa (job #1277152) | Cod sursa (job #3224061) | Cod sursa (job #3188976) | Cod sursa (job #1795575)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
struct pct{
double x, y;
};
int n;
double A;
pct p[100005];
double det( pct a, pct b, pct c);
int main()
{
int i;
fin>>n;
for(i=1; i<=n; ++i)
fin>>p[i].x>>p[i].y;
for(i=3; i<=n; ++i)
A=A+det(p[1], p[i-1], p[i]);
fout<<fixed<<setprecision(5)<<A<<'\n';
return 0;
}
double det( pct a, pct b, pct c)
{
return ((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))/2;
}