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 |
WHY PE?#include<stdio.h> #include<iostream> using namespace std; typedef struct point{ float x; float y; }point; int main() { point dog,gopher; point e; point escape; bool flag=false; float a,b; scanf("%f%f%f%f",&gopher.x,&gopher.y,&dog.x,&dog.y); while(scanf("%f%f",&e.x,&e.y)!=EOF) { a=4*((gopher.x-e.x)*(gopher.x-e.x)+(gopher.y-e.y)*(gopher.y-e.y)); b=((dog.x-e.x)*(dog.x-e.x)+(dog.y-e.y)*(dog.y-e.y)); if(flag==false&&a<b) { flag=true; escape=e; break; } } if(flag==false) { printf("The gopher cannot escape.\n"); } if(flag==true) { printf("The gopher can escape through the hole at(%.3f,%.3f).\n",escape.x,escape.y); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator