Cod sursa(job #2300082)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 10 decembrie 2018 20:51:52
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
long long int n,i;
double a,s;
struct punct{
    double x,y;
}v[100001],p;
int c_p(punct a, punct o, punct b)
{
    int d=( a.x - o.x ) * ( b.y - o.y ) - ( b.x - o.y) * ( a.y - o.y );
    return d;
}

int main()
{
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>v[i].x>>v[i].y;
    }
    p.x=0;
    p.y=0;
    for(i=1;i<n;i++)
    {
       a=c_p(v[i],p,v[i+1])/2;
       s=s+a;
    }
      a=c_p(v[n],p,v[1])/2;
       s=s+a;
    fout<<s;

    return 0;
}