poj 2007 Scrambled Polygon
#include<stdio.h> #include<algorithm> using namespace std; #define Max 60 struct Point { int x,y; } p[Max]; int xmult(Point p1,Point p2,Point p0) { return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y); } int pos; bool cmp(Point p1,Point p2) { if(xmult(p1,p2,p[pos])>0) return true; return false; } int main() { int i,n=0; while(scanf("%d%d",&p[n].x,&p[n].y)!=EOF) { n++; //if(n==6)break; } for(i=1; i<n; i++) { pos=i-1; sort(p+i,p+n,cmp); } for(i=0; i<n; i++) printf("(%d,%d)\n",p[i].x,p[i].y); return 0; }