Cod sursa(job #2087372)

Utilizator stefanchistefan chiper stefanchi Data 13 decembrie 2017 15:37:45
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <cstdio>
#define NMAX 100 010
using namespace std;
int n;

double arie(double x1, double y1, double x2, double y2)
{
    double sol = x1*y2-y1*x2;
    return sol/2;
}
void read()
{4
-2 -2
2 -2
2 2
-2 2
    double x1,y1,x2,y2;
    double x,y;
    double sol = 0;
    freopen("aria.in","r",stdin);
    freopen("aria.out","w",stdout);
    scanf("%d\n%lf %lf",&n,&x1,&y1);
    x=x1;
    y=y1;
    for(int i = 1 ; i< n ; i++)
    {
        scanf("%lf %lf",&x2,&y2);
        sol+=arie(x1,y1,x2,y2);
        x1 = x2;
        y1 = y2;
    }
    sol+=arie(x1,y1,x,y);
    printf("%.5lf",sol);
}


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