Pagini recente » Cod sursa (job #321382) | Cod sursa (job #1159967) | Cod sursa (job #868552) | Cod sursa (job #2433461) | Cod sursa (job #1118649)
#include<fstream>
#include<cmath>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct QQ
{
double x;
double y;
};
int main()
{
int n,i;
long double space=0;
QQ x1, x2, x3;
f>>n;
if(n>2)
{
for(i=1; i<=n; ++i)
{
if(i==1)
{
f>>x1.x>>x1.y;
x3=x1;
}
else
{
f>>x2.x>>x2.y;
space+=x1.x*x2.y - x2.x*x1.y;
x1=x2;
}
}
x2=x3;
space+=x1.x*x2.y - x2.x*x1.y;
}
g<<fixed;
g.precision(5);
g<<space/2;
return 0;
}