求多边形面积(如HDU2036)

网友投稿 322 2022-08-27

求多边形面积(如HDU2036)

1,。

2:可将多边形分割成多个三角形(如果不是按逆时针或顺时针给定顺序的定点需要进行排序),利用海伦公式,求得面积,但不适用于凹多边形,例如 HDU 2036.

海伦公式如下:已知三角形各边a,b,c

S=sqrt(p(p-a)(p-b)(p-c))  其中p为半周长:p=(a+b+c)/2;

3:

HDU 2036 :

#include#include#include#include#include#include#include#include#includetypedef long long LL;using namespace std;typedef struct point{ int x,y;}point;point a[100];double area(point p,point q){ return p.x * q.y - q.x * p.y;}int main(){ int i,n; double sum; while(scanf("%d ",&n) != EOF && n) { for(i=0;i

2:可将多边形分割成多个三角形(如果不是按逆时针或顺时针给定顺序的定点需要进行排序),利用海伦公式,求得面积,但不适用于凹多边形,例如 HDU 2036.

海伦公式如下:已知三角形各边a,b,c

S=sqrt(p(p-a)(p-b)(p-c))  其中p为半周长:p=(a+b+c)/2;

3:

HDU 2036 :

#include#include#include#include#include#include#include#include#includetypedef long long LL;using namespace std;typedef struct point{ int x,y;}point;point a[100];double area(point p,point q){ return p.x * q.y - q.x * p.y;}int main(){ int i,n; double sum; while(scanf("%d ",&n) != EOF && n) { for(i=0;i

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:中消协点名肯德基,什么才是“盲盒营销”的正确打开方式?
下一篇:HDU 2028 Lowest Common Multiple Plus(LCM)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~