Pagini recente » Cod sursa (job #1509695) | Cod sursa (job #1115991) | Cod sursa (job #1619572) | Cod sursa (job #1756451) | Cod sursa (job #1115982)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
const int Nmax = 100002;
struct Point
{
float x, y;
Point(){}
Point( float _x, float _y ) : x( _x ), y( _y ) {}
friend istream& operator >> ( istream &f, Point &P )
{
f >> P.x >> P.y;
return f;
}
};
Point v[Nmax];
int N;
float area( Point A, Point B, Point C )
{
return abs( A.x * B.y + B.x * C.y + C.x * A.y - B.x * A.y - C.x * B.y - A.x * C.y ) / 2.0;
}
int main()
{
ifstream f("aria.in");
ofstream g("aria.out");
f >> N;
for ( int i = 1; i <= N; ++i )
{
f >> v[i];
}
float A = 0;
for ( int i = 2; i < N; ++i )
{
A += area( v[1], v[i], v[i + 1] );
}
g << fixed << setprecision( 7 );
g << A << "\n";
return 0;
}