Cod sursa(job #2021670)

Utilizator VladUdriVlad Udrescu VladUdri Data 14 septembrie 2017 11:21:52
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("aria.in");
ofstream g("aria.out");

long double sum;
long double x_1, x_2, y_1, y_2;
int n;

int aria(long double x_1, long double x_2, long double y_1, long double y_2){
    long double t = 0.5;
    t *= (x_1 * y_2 - x_2 * y_1);
    return t;

}
int main()
{
    f >> n;
    f >> x_1 >> y_1;

    long double r_1, r_2;
    r_1 = x_1; r_2 = y_1;

    for(int i = 2; i <= n; ++i){
        f >> x_2 >> y_2;
        sum += aria(x_1, x_2, y_1, y_2);

        x_1 = x_2; y_1 = y_2;
    }
    sum += aria(x_1, r_2, y_1, r_2);

    g << fixed << setprecision(3) << sum;
}