poj 2007(极角排序)

来源:互联网 发布:淘宝新款女装 编辑:程序博客网 时间:2024/05/18 00:14
#include<stdio.h>#include<algorithm>using namespace std;struct  POINT{double x,y;}point[55];double cross(const POINT &p1,const POINT &p2,const POINT &q1,const POINT &q2) {    return (q2.y - q1.y)*(p2.x - p1.x) - (q2.x - q1.x)*(p2.y - p1.y);    }bool cmp(const POINT &a,const POINT &b){  POINT  origin;    origin.x=origin.y=0;return cross(origin,b,origin,a)<0;}int main(){int count=0;while(scanf("%lf %lf",&point[count].x,&point[count].y)!=EOF){count++;}   sort(point+1,point+count,cmp);  for(int i=0;i<count;i++)printf("(%.lf,%.lf)\n",point[i].x,point[i].y);return 0;}