//任意多边形的面积计算
#include <iostream>
#include <utility>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
typedef std::pair<double ,double> point;
#pragma warning(disable:4244)
double det(point p0,point p1,point p2)
{
return (p1.first-p0.first)*(p2.second-p0.second)-(p1.second-p0.second)*(p2.first-p0.first);
}
double ploygon_area(int n,point p[])
{
double s=0.0f;
int i=1;
for(;i < n-1;i++)
s += det(p[0],p[i],p[i+1]);
return 0.5*fabs(s);
}
int main(int argc, char *argv[])
{
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载