Cod sursa(job #2031129)
Utilizator | Palade Thomas-Emanuel justsomedude | Data | 2 octombrie 2017 19:18:44 |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include<fstream>
#include<cmath>
#include<iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int main()
{
int i, n;
long double s, x1, y1, x2, y2, aux1, aux2;
fin >> n;
fin >> x1 >> y1;
aux1=x1; aux2=y1;
s=0;
for (i=2; i<=n; i++)
{
fin >> x2 >> y2;
s = s + (x1*y2-x2*y1);
x1=x2; y1=y2;
}
s += (x1*aux2-aux1*y1);
s=fabs(s);
s=s/2;
fout<<fixed<<setprecision(5)<<s;
return 0;
}