Pagini recente » Cod sursa (job #1873740) | Cod sursa (job #84960) | Cod sursa (job #53235) | Cod sursa (job #38010) | Cod sursa (job #2270907)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct point
{
double x, y;
};
double sf(int n)
{
long double surface = 0;
point p1, p2, ps;
if (n < 3)
return 0;
f >> ps.x >> ps.y >> p2.x >> p2.y;
p1 = ps;
for (int i = 0; i < n; i++)
{
surface += (p1.x * p2.y - p2.x * p1.y);
p1 = p2;
f >> p2.x >> p2.y;
}
surface += (p2.x * ps.y - ps.x * p2.y);
return surface / 2;
}
int main()
{
int n;
f >> n;
double x = sf(n);
long long x1 = (long long)x;
if (x < 0) x = -x;
g << x1 << ".";
x -= x1;
if (x != 0)
g << (int)(x * 1000000);
else g << 0;
return 0;
}