Cod sursa(job #2241258)

Utilizator AnDrEeA1915Monea Andreea AnDrEeA1915 Data 15 septembrie 2018 13:37:21
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <iostream>
#include<fstream>
#include <math.h>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");

int main()
{
    int n;
    long double x1, y1, x2, y2, x, y, ans = 0;
    fin >> n >> x1 >> y1;
    x2 = x1 ;
    y2 = y1;
    for (int i = 1 ; i <= n; ++i){
        fin >> x >> y;
        ans += (x1*y - x*y1);
        x1 = x;
        y1 = y;
     }
     ans +=(x1*y2 - x2*y1);
     ans = ans /2.0;
     fout << fabs(ans);
     return 0;
}