Pagini recente » Cod sursa (job #894747) | Cod sursa (job #1884104) | Cod sursa (job #1176791) | Cod sursa (job #722313) | Cod sursa (job #1801768)
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct vector2{
double x,y;
};
double arie(vector2 a,vector2 b,vector2 c)
{
return a.x * b.y + a.y * c.x + b.x * c.y - a.x * c.y - a.y * b.x - b.y * c.x;
}
int n;
double A;
vector2 Or;
vector2 lst,act;
int main()
{
fin>>n;
fin>>Or.x >>Or.y;
fin>>lst.x>>lst.y;
for(int i=1;i<=n;i++)
{
fin>>act.x>>act.y;
A+= arie(Or,lst,act);
lst = act;
}
fout<<std::setprecision(6);
fout<<std::fixed;
fout<<abs(A) / 2<<'\n';
return 0;
}