Pagini recente » Cod sursa (job #1347144) | Cod sursa (job #346895) | Cod sursa (job #2964528) | Istoria paginii runda/oni_2007_ziua1_clasele_xi-xii/clasament | Cod sursa (job #2558658)
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream f ("aria.in");
ofstream g ("aria.out");
int n;
double AriaPoligon;
struct punct {
int x, y;
}v[100015];
void read ()
{
int i, xx, yy;
f >> n;
for (i=1; i<=n; i++)
{
f >> xx >> yy;
v[i].x = xx;
v[i].y = yy;
}
n ++;
v[n].x = v[1].x;
v[n].y = v[1].y;
}
void solve ()
{
int i, j;
for (i=1; i<=n-1; i++)
{
j = i + 1;
AriaPoligon += (v[i].x * v[j].y);
AriaPoligon -= (v[j].x * v[i].y);
}
if (AriaPoligon < 0)
AriaPoligon = -AriaPoligon;
AriaPoligon /= 2.0;
g << fixed << setprecision(6) << AriaPoligon;
}
int main()
{
read();
solve();
return 0;
}