标签:
5 0 0 0 4 4 0 4 4 2 3
16.000000
昨天百度搜了看了别人的代码。。我现在也不知道什么意思具体的思想。先写上,以后再想想~~
#include<iostream> #include<stdio.h> using namespace std; struct point { double x; double y; }; double max(double a,double b) { if(a>b) return a; else return b; } double area(point a0,point a1,point a2) { return (a0.x*a1.y+a1.x*a2.y+a2.x*a0.y-a1.x*a0.y-a2.x*a1.y-a0.x*a2.y)/2; } int main() { int n,i,j,k; point Point[300]; while(cin>>n) { double s,lmax,rmax,ans=0; for(i=0;i<n;i++) cin>>Point[i].x>>Point[i].y; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { lmax=rmax=0; for(k=0;k<n;k++) { if(i!=k &&j!=k) { s=area(Point[i],Point[j],Point[k]); if(s<1e-10) lmax=max(lmax,-s); else rmax=max(rmax,s); } } if(lmax==0 ||rmax==0) continue; ans=max(ans,(lmax+rmax)); } } printf("%.6lf\n",ans); } return 0; }
标签:
原文地址:http://blog.csdn.net/zuguodexiaoguoabc/article/details/45504851