象限极角排序应用(有报酬)
int quad(point a)// 判断象限的函数,每个象限包括半个坐标轴 {
if( dy(a.x,0) && xyd(a.y,0) ) return 1;
if( xyd(a.x,0) && dy(a.y,0) ) return 2;
if( xy(a.x,0) && xyd(a.y,0) ) return 3;
if( dyd(a.x,0) && xy(a.y,0) ) return 4;
}
bool cmp(point& a,point& b)
{
point p1 = a,p2 = b;
p1.x -= C.x; p1.y -= C.y;
p2.x -= C.x; p2.y -= C.y;
int l1,l2;
l1 = quad(p1); l2 = quad(p2);
if( l1 == l2 )
{
double c = crossProduct(C,a,b);
return xy(c,0) || dd(c,0.0) && xy(fabs(a.x),fabs(b.x));
}
return l1 < l2;
}