Cod sursa(job #1892707)

Utilizator stefanchistefan chiper stefanchi Data 25 februarie 2017 11:05:12
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
double s;
struct coord{
    double x,y;
}vec[100001];
void read()
{
    freopen("aria.in","r",stdin);
    freopen("aria.out","w",stdout);
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
        scanf("%lf %lf",&vec[i].x,&vec[i].y);
    vec[n]=vec[0];
    for(int i = 0 ; i < n ; ++i)
        s += (vec[i].x*vec[i+1].y - vec[i+1].x*vec[i].y);\
    printf("%lf",fabs(s/2.0));
}

int main()
{
    read();
    return 0;
}