Pagini recente » Cod sursa (job #697463) | Cod sursa (job #163501) | Cod sursa (job #1898505) | Cod sursa (job #470941) | Cod sursa (job #1094881)
#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;
}