| ||||||||||
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 |
为什么会wa??求高手帮忙看看!!谢谢^_^#include"stdio.h" #define f 0.00000001 struct point{ double x;double y; }l[2][105]; int judge(struct point a,struct point b,struct point c){ double l=a.x*b.y+b.x*c.y+c.x*a.y-a.y*b.x-b.y*c.x-c.y*a.x; if(l>0.0)return 1; else if(l<0.0)return -1; else return 0; }//1代表右边,-1代表左边,0代表在直线上 int main(){ int T,find; scanf("%d",&T); while(T--){ int i,j,k,n; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%lf %lf %lf %lf",&l[0][i].x,&l[0][i].y,&l[1][i].x,&l[1][i].y);//直线起点存在l【0】,终点l[1] if(n==1||n==2)find=1; else { for(i=1;i<=n;i++){ //枚举所有的点,先选中一条 for(j=i+1;j<=n;j++){ //再选一条 for(k=1;k<=n;k++) //选中两条直线的端点产生的四条直线L分别判断与其他直线是否相交 if(judge(l[0][i],l[0][j],l[0][k])*judge(l[0][i],l[0][j],l[1][k])==1){find=0; break;} else find=1; if(find)break; for(k=1;k<=n;k++) if(judge(l[0][i],l[1][j],l[0][k])*judge(l[0][i],l[1][j],l[1][k])==1){find=0;break;} else find=1; if(find)break; for(k=1;k<=n;k++) if(judge(l[1][i],l[0][j],l[0][k])*judge(l[1][i],l[0][j],l[1][k])==1){find=0;break;} else find=1; if(find)break; for(k=1;k<=n;k++) if(judge(l[1][i],l[1][j],l[0][k])*judge(l[1][i],l[1][j],l[1][k])==1){find=0;break;} else find=1; if(find)break; } if(find)break; } } if(find)printf("Yes!\n"); else printf("No!\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator