Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我的想法,比较简单点 大家可以看看

Posted by zouziwen at 2010-01-27 13:38:50 on Problem 1410
In Reply To:我的想法,比较简单点 大家可以看看 Posted by:thisissqy0619 at 2009-07-19 06:37:37
> //我从反面考虑,将不相交的情况列举出来
> 
> #include <stdio.h>
> 
> int main()
> {
> 	int x1,y1,x2,y2,xl,yt,xr,yb,i,n,a,b,c,f1,f2,f3,f4,temp;
> 	scanf("%d",&n);
> 	for(i=0;i<n;i++)
> 	{
> 		scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&xl,&yt,&xr,&yb);
> 		if(xl>xr)
> 		{
> 			temp=xl;
> 			xl=xr;
> 			xr=temp;
> 		}
> 		if(yt<yb)
> 		{
> 			temp=yt;
> 			yt=yb;
> 			yb=temp;
> 		}
> 		a=y1-y2;
> 		b=x2-x1;
> 		c=x1*y2-y1*x2;
> 		f1=a*xl+b*yb+c;
> 		f2=a*xl+b*yt+c;
> 		f3=a*xr+b*yb+c;
> 		f4=a*xr+b*yt+c;
> 		if(f1>0&&f2>0&&f3>0&&f4>0||f1<0&&f2<0&&f3<0&&f4<0) //判断线段所在直线是否与矩形相交
> 			printf("F\n");
> 		else if((x1>xr&&x2>xr)||(x1<xl&&x2<xl))//若线段所在直线与矩形相交,则满足一下两种情况的时候线段不与矩形相交
> 			printf("F\n");
> 		else if((y1>yt&&y2>yt)||(y1<yb&&y2<yb))
> 			printf("F\n");
> 		else
> 			printf("T\n");
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator