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

哪里有错误啊?!!!请大牛帮帮忙啊!!!

Posted by 13227183 at 2008-07-26 10:52:16 on Problem 2610
/* 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:
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