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

要处理长度为0的情况 和w l 为0 的情况

Posted by ecjtunh at 2006-10-21 19:03:53
In Reply To:我的代码,一直wa,哪位给看看,谢了! Posted by:zhj5825 at 2006-10-21 19:02:15
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
> #include<math.h>
> 
> 
> 
> typedef struct point
> {
>     double x;
>     double y;        
> }point;
> 
> point pos(double ,double ,char,int,int);
> 
> main()
> {
>     int w,l;
>     double x0,y0,x1,y1,ans=0;
>     int i;
>     point p;
>     while (scanf("%d %d",&w,&l)!=EOF)
>     {
>         char direction[1000];
>         ans=0;
>         p.x=0;
>         p.y=0;
>         scanf("%lf %lf",&x0,&y0);
>         scanf("%lf %lf",&x1,&y1);
>         scanf("%s",direction); 
>        // printf("%s\n",direction);
>         int len=strlen(direction);
>         //printf("len=%d\n",len);
>         
>         for (i=0;i<len;i++)
>         {
>             p=pos(x0,y0,direction[i],w,l);
>             x0=p.x;
>             y0=p.y;        
>         }     
>         ans=sqrt((p.x-x1)*(p.x-x1)+(p.y-y1)*(p.y-y1));
>      
>         printf("%.4lf\n",ans);
>     }
> }
> point pos(double x,double y,char dir,int w,int l)
> {
>      
>     point ans;
>     if (dir=='F')
>     {
>         ans.x=x;
>         ans.y=-y;                     
>     }       
>     if (dir=='L')
>     {
>         ans.x=-x;
>         ans.y=y;     
>     }
>     if (dir=='B')
>     {
>         ans.x=x;
>         ans.y=2*l-y;     
>     }
>     if (dir=='R')
>     {
>         ans.x=2*w-x;
>         ans.y=y;    
>     }
>     return ans;
> }

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