Cod sursa(job #3250337)

Utilizator 0021592Grecu rares 0021592 Data 20 octombrie 2024 11:41:53
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.66 kb
#include <fstream>
#include <iomanip>
#define double long double
using namespace std;
ifstream in("aria.in");
ofstream out("aria.out");
double n, i, j, ar;
struct dur
{
    double x, y;
}a, b, c, that;
double abs(double x)
{
    if (x > 0)
        return x;
    return -x;
}
int main()
{
    in >> n;
    in >> b.x >> b.y; that = b;
    for (i = 2; i <= n; i++)
    {
        in >> c.x >> c.y;
        ar += (a.x * b.y + a.y * c.x + b.x * c.y - a.x * c.y - a.y * b.x - b.y * c.x);
        b = c;
    }
    c = that;
    ar += (a.x * b.y + a.y * c.x + b.x * c.y - a.x * c.y - a.y * b.x - b.y * c.x);
    out << fixed << setprecision(5) << ar/2;
}