poj 2501 Average Speed

简介:

这种题目一定要小心。很容易处理不好输入输出!

懒得写了,直接参考代码。。。这个代码写的很好,思路很清晰,风格跟我的也很接近


#include <stdio.h>

int main()
{
	int h,m,s,hh=0,mm=0,ss=0,speed=0;
	double distance=0;

	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(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;
}



相关文章
POJ 2840 Big Clock
POJ 2840 Big Clock
111 0
|
人工智能
HDOJ/HDU 2710 Max Factor(素数快速筛选~)
HDOJ/HDU 2710 Max Factor(素数快速筛选~)
104 0
POJ 2840 Big Clock
Description Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days...
920 0
|
机器学习/深度学习 Java Go
|
机器学习/深度学习 人工智能