Cod sursa(job #3287624)

Utilizator Tudor28Ceclan Tudor Tudor28 Data 18 martie 2025 18:58:54
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.67 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Punct
{
    double x, y;
};
double AriaTriunghi(Punct A, Punct B)
{
    return (A.x * B.y - A.y * B.x);
}
int main()
{
    int n;
    fin >> n;
    Punct ext, first;
    fin >> ext.x >> ext.y;
    first = ext;
    double s = 0;
    for (int i = 0; i < n; i++)
    {
        Punct p;
        fin >> p.x >> p.y;
        s += AriaTriunghi(ext, p);
        ext = p;
    }
    s += AriaTriunghi(ext, first);
    s /= 2;

    fout << fixed << setprecision(6) << fabs(s);
    return 0;
}