| ||||||||||
| 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 | |||||||||
大牛过来看一下,那里错了?????????#include <stdio.h>
#include <math.h>
__int64 x[105],y[105];
//求两直线的交点
bool dot(__int64 x1,__int64 y1,__int64 x2,__int64 y2,__int64 x3,__int64 y3,__int64 x4,__int64 y4)
{
double tx=x1,ty=y1;
__int64 t1=x1-x3,t2=y3-y4,t3=y1-y3,t4=x3-x4;
__int64 s1=x1-x2,s2=y3-y4,s3=y1-y2,s4=x3-x4;
t1*=t2,t3*=t4,s1*=s2,s3*=s4;
t1-=t3,s1-=s3;
if(s1==0) return 0;
double t=t1/double(s1);
tx+=(x2-x1)*t;
ty+=(y2-y1)*t;
if(fabs(tx)==0&&fabs(ty)==0)
return 1;
else
return 0;
}
int main()
{
int n,m,i,a,b,c,d;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%I64d%I64d",&x[i],&y[i]);
scanf("%d",&m);
bool flag=0;
for(i=1;i<=m;i++)
{
scanf("%d%d%d%d",&a,&b,&c,&d);
flag=dot(x[a],y[a],x[b],y[b],x[c],y[c],x[d],y[d]);
if(flag)
break;
}
if(flag)
printf("%d\n",i);
else
printf("0\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