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

水题,1A,附代码

Posted by bryant03 at 2014-08-17 08:41:58 on Problem 2501
#include <stdio.h>
int main()
{
	int h,m,s,hh=0,mm=0,ss=0,speed=0;
	double distance=0;
	char c;
	while(scanf("%d:%d:%d",&h,&m,&s)!=EOF)
	{
		distance+=(h-hh)*speed+(m-mm)*speed/60.0+(s-ss)*speed/3600.0;
		hh=h,mm=m,ss=s;
		if(c=getchar()==' ')
			scanf("%d",&speed);
		else
		{
			if(h<10)
				printf("0%d:",h);
			else printf("%d:",h);
			if(m<10)
				printf("0%d:",m);
			else printf("%d:",m);
			if(s<10)
				printf("0%d ",s);
			else printf("%d ",s);
			printf("%.2lf km\n",distance);
		}
	}
	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