Mai intai trebuie sa te autentifici.

Cod sursa(job #1363576)

Utilizator AdrianaMAdriana Moisil AdrianaM Data 27 februarie 2015 02:46:39
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <fstream>
#include <vector>
#include <cmath>
using namespace std;

ifstream is("aria.in");
ofstream os("aria.out");

using VD = vector<double>;

int n;
double s;
VD x, y;

int main()
{
    is >> n;
    x = y = VD(n + 2);
    for ( int i = 1; i <= n; ++i )
        is >> x[i] >> y[i];
    x[n + 1] = x[1];
    y[n + 1] = y[1];
    for ( int i = 1; i <= n; ++i )
        s += x[i] * y[i + 1] - x[i + 1] * y[i];
    os << fabs(s / 2.0);
    is.close();
    os.close();
    return 0;
}