Pagini recente » Cod sursa (job #2986835) | Cod sursa (job #838720) | Cod sursa (job #193998) | Cod sursa (job #1869562) | Cod sursa (job #1128561)
#include<stdio.h>
#include<fstream>
#include<iomanip>
#include<utility>
using namespace std;
FILE *in;
//definitii
#define x first
#define y second
#define pdd pair<double,double>
//functii
long double det(pdd a, pdd b, pdd c);
//variabile
ofstream out("aria.out");
int n;
pdd fix,curent,precedent;
long double aria;
int main(void)
{
in=fopen("aria.in","rt");
fscanf(in,"%d",&n);
fscanf(in,"%lf%lf",&fix.x,&fix.y);
fscanf(in,"%lf%lf",&precedent.x,&precedent.y);
for(int i=3 ; i<=n ; ++i)
{
fscanf(in,"%lf%lf",&curent.x,&curent.y);
aria += det(fix,precedent,curent);
precedent = curent;
}
out << fixed << setprecision(5) << aria/2.0;
out << '\n';
fclose(in);
out.close();
return 0;
}
long double det(pdd a, pdd b, pdd c)
{
return a.x * b.y + a.y * c.x + b.x * c.y - b.y * c.x - a.y * b.x - a.x * c.y;
}