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 |
哪里有错误啊?!!!请大牛帮帮忙啊!!!/* Note:Your choice is C IDE */ #include "stdio.h" #include "math.h" const double eps=1*-6; double holex,holey,holexx,holeyy; double distance(double x,double y) { return (x-holex)*(x-holex)+(y-holey)*(y-holey); } double distance2(double x,double y) { return (x-holexx)*(x-holexx)+(y-holeyy)*(y-holeyy); } void main() { int flag=0,i=0; double x,y,dogx,dogy; scanf("%lf%lf%lf%lf",&x,&y,&dogx,&dogy); while(scanf("%lf%lf",&holex,&holey)!=EOF) { if(distance(dogx,dogy)-4*distance(x,y)>eps) { flag=1; i++; } if(i!=0) { if(i==1) {holexx=holex;holeyy=holey;} else { if((distance(dogx,dogy)-4*distance(x,y))-(distance2(dogx,dogy)-4*distance2(x,y))>eps) { holexx=holex;holeyy=holey; } } } } if(flag==1) printf("The gopher can escape through the hole at (%.3lf,%.3lf).\n",holexx,holeyy); if(flag==0) printf("The gopher cannot escape.\n"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator