码迷,mamicode.com
首页 > 编程语言 > 详细

象限极角排序

时间:2016-07-23 21:02:16      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:

struct Point
{
    int id;
    LL x,y;
    Point(){}
    Point(LL x,LL y):x(x),y(y){}
    void Read(){scanf("%I64d%I64d",&x,&y);}
    LL operator^(const Point P)const{return x*P.y-y*P.x;}
    Point operator-(const Point P)const{return Point(x-P.x,y-P.y);}
}me[10],mos[1050],tmp[1050];
int quad(Point a)
{
    if(a.x>0 && a.y>=0) return 1;
    if(a.x<=0 && a.y>0) return 2;
    if(a.x<0 && a.y<=0) return 3;
    if(a.x>=0 && a.y<0) return 4;
}

bool cmp(Point a,Point b)
{
    int l1=quad(a),l2=quad(b);
    if(l1==l2)
    {
        LL c=a^b;
        return c<0LL || (c==0LL && a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y);
    }
    return l1<l2;
}
bool Equal(Point a,Point b)
{
    int l1=quad(a),l2=quad(b);
    return l1==l2&&(a^b)==0;
}

 

象限极角排序

标签:

原文地址:http://www.cnblogs.com/tun117/p/5699389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!