holiday/8.10/G - change.cpp

41 lines
708 B
C++

//G - ¸Ä¸ï´º·ç´µÂúµØ
//https://vjudge.net/contest/508277#problem/G
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N=101;
double ans;
int n,j;
struct dot
{
int x,y;//int->double
} a[N];
double cross(double x1,double y1,double x2,double y2)
{
// printf("(%d,%d)(%d,%d):%d\n",x1,y1,x2,y2,x1*y2-x2*y1) ;
return x1*y2-x2*y1;
}
int main()
{
while(1)
{
scanf("%d",&n);
if(n==0) return 0;
ans=0;
memset(a,0,sizeof(dot)*(n+1));
for(int i=1; i<=n; i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
for(int i=1; i<=n; i++)
{
j=i%n+1;
ans+=(cross(a[i].x,a[i].y,a[j].x,a[j].y)/2);
}
printf("%.1lf\n",ans);//Presentation Error
}
return 0;
}