Pagini recente » Cod sursa (job #96397) | Cod sursa (job #1963977) | Cod sursa (job #2746714) | Cod sursa (job #1057288) | Cod sursa (job #2088751)
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct point
{
int x, y;
};
double area(point a, point b, point c)
{
a.x-=c.x, a.y-=c.y;
b.x-=c.x, b.y-=c.y;
return fabs((double)(a.x*b.y-a.y*b.x)/2);
}
long double arie;
int n, i, j;
int main()
{
fin>>n;
point a;
fin>>a.x>>a.y;
point b;
fin>>b.x>>b.y;
point c;
for(i=3;i<=n;i++)
{
fin>>c.x>>c.y;
arie+=area(a,b,c);
b.x=c.x,b.y=c.y;
}
fout<<setprecision(5)<<fixed<<arie;
return 0;
}