Cod sursa(job #1762629)

Utilizator CaterpillerLeaf Caterpiller Caterpiller Data 23 septembrie 2016 22:05:59
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <fstream>

int main()
{
    std::ifstream input("aria.in");
    std::ofstream output("aria.out");
    int n;
    double aria = 0;

    input >> n;
    double first_x, first_y, prev_x, prev_y, x, y;
    input >> x >> y;
    first_x = x;
    first_y = y;
    for(int i = 1; i < n; ++i) {
        prev_x = x;
        prev_y = y;
        input >> x >> y;
        aria += prev_x * y - prev_y * x;
    }
    aria += x * first_x - y * first_y;
    aria /= 2;
    output << aria << '\n';

    return 0;
}