Cod sursa(job #2426480)

Utilizator laraamy16Cioc Amelia laraamy16 Data 28 mai 2019 11:47:06
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.48 kb
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream f("arie.in");
ofstream g("arie.out");
int main()
{
    int n, x1, y1, x2, y2, xp, yp;
   long double s = 0;
   xp = x1;
    yp = y1;
    for(int i = 2; i <= n; i++)
    {
        f >> x2 >> y2;
        s += x1 * y2 - x2 * y1;
        x1 = x2;
        y1 = y2;
    }
    s += x2 * yp - y2 * xp;
    s /= 2;

    g << fixed << setprecision(5) << s;
    return 0;
}