Connecting address of the portal
The main topic: give you a number n, and then give the N coordinate values (two-dimensional), let you seek area;
Problem-Solving ideas: cross product, pay attention to the final absolute value, but also divided by 2 ah ...
On the code:
#include <iostream>#include <cstdio>#include <cmath>using namespace STD;Const intmaxn=1e4+5;structpoint{DoubleXDoubleY;} DATA[MAXN];DoubleChaji (structPoint A,structPoint B) {returna.x*b.y-a.y*b.x;//Seek cross product}intMain () {intM while(Cin>>M,M) {Doublesum=0; for(intI=0; i<m; i++)Cin>>data[i].x>>data[i].y; for(intI=1; i<=m; i++) Sum+=chaji (data[i-1],DATA[I%M]);//cout<< (int) fabs (sum)/2<<endl; printf("%d\n",(int)fabs(SUM)/2);//(int) fabs (sum)/2}return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
POJ 3907 Build Your Home