Cod sursa(job #1918914)

Utilizator zeboftwAlex Mocanu zeboftw Data 9 martie 2017 17:20:44
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <fstream>
#include <queue>

using namespace std;

ifstream fin("arie.in");
ofstream fout("arie.out");

struct punct {
double x, y;
};

queue<punct> coada;

double aria (punct p2, punct p3) {
    return (p2.x * p3.y - p2.y * p3.x) / 2;
}

int main()
{
    int n;
    double sum = 0;
    punct save, A, B;

    fin >> n >> save.x >> save.y;

    A = save;

    n--;
    while (n) {
        fin >> B.x >> B.y;
        sum += aria(A, B);
        A=B;
        n--;
    }
    sum += aria(B, save);

    fout << sum;

    return 0;
}