poj 3907 Build Your Home 多边形面积

题意:

给一个多边形,,求它的面积。

分析:

算一遍叉积即可。

代码:

//poj 3907//sep9#include <iostream>#include <cmath>using namespace std;int main(){float x0,y0,x1,y1;short n;while(scanf("%hd",&n)==1&&n){float sum=0;scanf("%f%f",&x0,&y0);float xx=x0,yy=y0;n–;while(n–){scanf("%f%f",&x1,&y1);sum+=x0*y1-x1*y0;x0=x1;y0=y1;}x1=xx;y1=yy;sum+=x0*y1-x1*y0;printf("%.0f\n",fabs(sum)/2+1e-6);}return 0;}

像一颗深绿色的宝石镶嵌在云南大地上,

poj 3907 Build Your Home 多边形面积

相关文章:

你感兴趣的文章:

标签云: