| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我也来说几句我的想法注意输入,前面有人说了
1.排除线段在矩形上下左右四周的情况,F
2.排除线段在矩形内部的情况,T
3.调用两次检查两个点是否分在直线两侧,即将两个点的坐标代入直线方程
bool f(int a,int b,int c,int d) //(a,b) (c,d)两点
{
int p=(y2-y1)*(a-x1)-(b-y1)*(x2-x1);
int q=(y2-y1)*(c-x1)-(d-y1)*(x2-x1);
if(p*q>0) return false; //相交
else return true; //不相交
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator