Cod sursa(job #2670115)

Utilizator Katherine456719Swan Katherine Katherine456719 Data 9 noiembrie 2020 07:35:17
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include <bits/stdc++.h>
using namespace std;
pair <double,double> coord[100005];
ifstream fin("aria.in");
ofstream fout("aria.out");
int main() {
    int n;
    long double arie = 0;
    fin >> n;
    for(int i = 1;i <= n; ++i)
        fin >> coord[i].first >> coord[i].second;
    for(int i = 1;i < n; ++i)
        arie += coord[i].first * coord[i+1].second - coord[i+1].first * coord[i].second;
    arie += coord[n].first * coord[1].second - coord[1].first * coord[n].second;
    fout << setprecision(5) << fixed << arie / 2;
    return 0;
}