标签:art blocks poj rac ica cat string pen isp
题目大意:按逆时针方向连接个点,并将其输出,第一个点为(0,0)。
题目思路:叉积排下序就好了
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<queue> #define INF 0x3f3f3f3f #define MAX 100005 #define PI acos(-1) using namespace std; struct node { int x,y; } point[MAX]; int Stuck[MAX],pos,cnt; int Cross(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4) { return (x1-x2)*(y3-y4)-(x3-x4)*(y1-y2); } bool cmp(struct node A,struct node B) { if(Cross(0,0,A.x,A.y,0,0,B.x,B.y)>=0) return true; return false; } int main() { int x,y; cnt=0; while(scanf("%d%d",&x,&y)!=EOF) { point[cnt].x=x; point[cnt].y=y; cnt++; } sort(point+1,point+cnt,cmp); for(int i=0;i<cnt;i++) printf("(%d,%d)\n",point[i].x,point[i].y); return 0; }
POJ 2007 Scrambled Polygon(极角排序)
标签:art blocks poj rac ica cat string pen isp
原文地址:http://www.cnblogs.com/alan-W/p/6030550.html