Cod sursa(job #2777548)
Utilizator | Ioana Popa ioana0211 | Data | 23 septembrie 2021 18:06:14 |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
int n;
long double arie=0;
struct punct
{
long double x;
long double y;
};
punct p[100010];
int main()
{
fin>>n;
for(int i=1; i<=n; i++)
fin>>p[i].x>>p[i].y;
p[n+1]=p[1];
for(int i=1; i<=n; i++)
arie+=(p[i].y+p[i+1].y)*(p[i+1].x-p[i].x)/2;
fout<<fixed<<setprecision(15)<<abs(arie);
return 0;
}