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 ync at 2005-08-01 15:29:53 on Problem 2501
In Reply To:我的程序给---谁我看看!!!! why WA? Posted by:ync at 2005-08-01 15:28:57
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
> int main()
> {
> 	char ch[40];
> 	int h,m,s,speed,speed2,len,h1,m1,s1,h2,m2,s2;
>     double dis,t;
> 	dis=0;  speed=speed2=0;
>     while(gets(ch)!=NULL)
> 	{
> 	  len=strlen(ch);
> 	  if(len>10) 
> 	  {
>          h2=(ch[0]-'0')*10+ch[1]-'0';
> 		 m2=(ch[3]-'0')*10+ch[4]-'0';
> 		 s2=(ch[6]-'0')*10+ch[7]-'0';
> 		 speed=atoi(ch+9); 
> 		if(speed2!=0)
>    dis=dis+speed2*((h2-h)+(m2-m)/60.0+(s2-s)/3600.0);
> 		 h=h2; m=m2; s=s2;  speed2=speed;
> 		// printf("dis=%.2f\n",dis);
> 		 //printf("%d %d %d %d\n",h,m,s,speed);
> 	  }
> 	 else 
> 	 {
> 
> 		h1=(ch[0]-'0')*10+ch[1]-'0';
> 		 m1=(ch[3]-'0')*10+ch[4]-'0';
> 		 s1=(ch[6]-'0')*10+ch[7]-'0';
>          t=(h1-h)+(m1-m)/60.0+(s1-s)/3600.0;
> 		 dis=dis+t*speed; printf("%s %.2f km\n",ch,dis);
> 		 h=h1; m=m1; s=s1; 
> 		 
> 	 }
> 	}
> 	return 0;
> }

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