#include
#include
#include
#include
using namespace std;
/*多边形面积在计算机中有一个很好的处理办法就是相量叉乘,我们知道三角形OAB的面积可以等于1/2*|OA|*|OB|*sinAOB,也就是等于OAXOB的模
*若A(x1,y1),B(x2,y2),那么S=(x1*y2-x2*y1) / 2(若不除以2算的是平行四边形的面积)(选择坐标原点为O点),
*由此就可以求得三角形的面积(由于叉乘有正负,可处理凹多边形的情况)
*/
struct point{
int x;
int y;
};
int main(){
int n;
vector p;
point temp;
double area;
while(cin >> n){
p.clear();
area = 0.0;
if(n == 0){
break;
}
else{
for(int i = 0; i < n; i++){
cin >> temp.x;
cin >> temp.y;
p.push_back(temp);
}
}
for(int i = 0; i < p.size() - 1; i++){
area += 0.5*(p[i].x * p[i+1].y - p[i+1].x * p[i].y);
}
area += 0.5*(p[p.size()-1].x * p[0].y - p[0].x * p[p.size()-1].y);//最后一组要加上 p[p.size()1-1]不是p[p.size()] !!
cout<= 0 ? area: -area;
cout << area << endl;
}
return 0;
}
//===================================================================
//WA,递归求凸多边形面积,将多边形分成多个小三角形求解(只适用于凸多边形),求凸多边形时也可不用递归,按顶点0,1,2 0,2,3 0,3,4 讲每个小三角形加上即可
/*
#include
#include
#include
#include
using namespace std;
struct point{
int x;
int y;
};
double cal_area(vector po){//递归求多边形面积
double area = 0;
double a = 0, b = 0, c = 0, p = 0;
if(po.size() == 3){//递归出口,将多边形切割成多个小三角形求面积 , 只适用于凸多边形
a = sqrt( (po[0].x - po[1].x)*(po[0].x - po[1].x) + (po[0].y - po[1].y)*(po[0].y - po[1].y) );
b = sqrt( (po[1].x - po[2].x)*(po[1].x - po[2].x) + (po[1].y - po[2].y)*(po[1].y - po[2].y) );
c = sqrt( (po[0].x - po[2].x)*(po[0].x - po[2].x) + (po[0].y - po[2].y)*(po[0].y - po[2].y) );
p = (a + b + c) / 2;
area = sqrt(p * (p - a) * (p - b) * (p - c));
return area;
}
else{
int div;
div = po.size() / 2;
vector t1;
vector t2;
t1.clear();
t2.clear();
for(int i = 0; i <= div; i++){
t1.push_back(po[i]);
}
for(int i = div; i < po.size(); i++){
t2.push_back(po[i]);
}
t2.push_back(po[0]);
return cal_area(t1) + cal_area(t2);
}
}
int main(){
int n;
vector p;
point temp;
double area;
while(cin >> n){
p.clear();
if(n == 0){
break;
}
else{
for(int i = 0; i < n; i++){
cin >> temp.x;
cin >> temp.y;
p.push_back(temp);
}
}
area = cal_area(p);
cout<