Cod sursa(job #3222618)
| Utilizator | Data | 11 aprilie 2024 09:29:21 | |
|---|---|---|---|
| Problema | Aria | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include<fstream>
#include<cmath>
std::ifstream fin("aria.in");
std::ofstream fout("aria.out");
struct point{
long double x, y;
}vec[100005];
int main()
{
int n;
fin>>n;
for(int i=0; i<n; ++i)
fin>>vec[i].x>>vec[i].y;
vec[n]=vec[0];
long double arie=0;
for(int i=0; i<n; ++i)
arie+=(vec[i].x*vec[i+1].y-vec[i+1].x*vec[i].y);
fout<<fabs(arie/2.0);
return 0;
}