Cod sursa(job #1491585)

Utilizator SebastianCabaCaba Sebastian SebastianCaba Data 25 septembrie 2015 18:31:41
Problema Aria Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <fstream>
#include <cstdio>
using namespace std;


ifstream fin("aria.in");
ofstream fout("aria.out");
int n, i, j;
double A;
struct punct
{
    double x, y;
};
punct v[100005];

double Aria(int a, int b, int c)
{
    double n;
    n=v[a].x*v[b].y+v[b].x*v[c].y+v[c].x*v[a].y-v[c].x*v[b].y-v[b].x*v[a].y-v[a].x*v[c].y;
    n=n/2.;
    if(n<0)n=-n;

    return n;

}



int main()
{
    freopen("aria.out", "w", stdout);
    fin>>n;
    for(i=1; i<=n; i++)
        fin>>v[i].x>>v[i].y;
    for(j=2; j<=n-1; j++)
        A=A+Aria(1,j,j+1);
    printf("%.6f", A);
    return 0;
}