Cod sursa(job #1118649)
Utilizator | Trifan Titus titustrifan | Data | 24 februarie 2014 12:27:15 |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.66 kb |
#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;
}