-
B - Scrambled Polygon
- POJ - 2007
- 按照与第一个点的夹角排序即可,
-
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define maxn 105 #define PR 1e-6 struct node { int x,y; } p[maxn]; double l,ans; int n,stk[maxn],top; double cha(node p0,node p1,node p2) { return (p1.x-p0.x)*(p2.y-p0.y)-(p1.y-p0.y)*(p2.x-p0.x); } bool cmp(node a,node b) { return ((cha(p[1],a,b)))>0; } int main() { n=1; while(~scanf("%d%d",&p[n].x,&p[n].y)) n++; sort(p+2,p+n,cmp); int i; for(i = 1; i <n; i ++) printf("(%d,%d)\n",(p[i].x),(p[i].y)); return 0; }
B - Scrambled Polygon POJ - 极角排序
最新推荐文章于 2019-09-30 12:35:43 发布