Cod sursa(job #1690516)

Utilizator Adriana_VladoneAdriana Vladone Adriana_Vladone Data 15 aprilie 2016 11:09:17
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct pereche
{
    double ox, oy;
};
pereche v[100001];

FILE *in, *out;

int main()
{
    in=fopen("aria.in", "r");
    out=fopen("aria.out", "w");
    int N, i;
    double A, x, y;
    fscanf(in, "%d", &N);
    for(i=1; i<=N; i++)
    {
        fscanf(in, "%lf %lf\n", &x, &y);
        v[i].ox=x;
        v[i].oy=y;
    }
    A=v[N].ox*v[1].oy-v[1].ox*v[N].oy;
    for(i=1; i<=N-1; i++)
    {
         A=A+v[i].ox*v[i+1].oy-v[i+1].ox*v[i].oy;
    }
    A=A/2;
    if(A<=0)
    A=-A;
    fprintf(out, "%0.5f", A);
    fclose(in);
    fclose(out);
    return 0;
}