2501 Average Speed
2008-11-10 17:36
113 查看
/*
第一行的速度可能为0,故初始速度要为0
*/
#include<iostream>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int h,m,s,k(0);
int pres(0),nows,time;
double sum=0.0;
char c;
while(scanf("%d%c%d%c%d",&h,&c,&m,&c,&s)!=EOF)
{
c=getchar();
if(h==24)
h=0;
if(c!='/n')
{
if(pres!=0)
{
nows=s+m*60+h*60*60;
time=nows-pres;
sum+=time*k/3600.0;
}
cin>>k;
}
else
{
nows=s+m*60+h*60*60;
time=nows-pres;
if(k!=0)
sum+=time*k/3600.0;
if(h<10)
cout<<0<<h<<":";
else
cout<<h<<":";
if(m<10)
cout<<0<<m<<":";
else
cout<<m<<":";
if(s<10)
cout<<0<<s<<" ";
else
cout<<s<<" ";
printf("%0.2lf km/n",sum);
}
pres=s+m*60+h*60*60;
}
return 0;
}
关键是输出格式的处理,还又要注意 24小时变为0小时
第一行的速度可能为0,故初始速度要为0
*/
#include<iostream>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int h,m,s,k(0);
int pres(0),nows,time;
double sum=0.0;
char c;
while(scanf("%d%c%d%c%d",&h,&c,&m,&c,&s)!=EOF)
{
c=getchar();
if(h==24)
h=0;
if(c!='/n')
{
if(pres!=0)
{
nows=s+m*60+h*60*60;
time=nows-pres;
sum+=time*k/3600.0;
}
cin>>k;
}
else
{
nows=s+m*60+h*60*60;
time=nows-pres;
if(k!=0)
sum+=time*k/3600.0;
if(h<10)
cout<<0<<h<<":";
else
cout<<h<<":";
if(m<10)
cout<<0<<m<<":";
else
cout<<m<<":";
if(s<10)
cout<<0<<s<<" ";
else
cout<<s<<" ";
printf("%0.2lf km/n",sum);
}
pres=s+m*60+h*60*60;
}
return 0;
}
关键是输出格式的处理,还又要注意 24小时变为0小时
相关文章推荐
- poj 2501 Average Speed
- POJ 2501 Average Speed --from lanshui_Yang
- POJ 2501 Average Speed(不错的一道水题)
- POJ 2501 Average Speed(水~)
- POJ 2501 Average Speed 好好学习博友的文章
- PKU_ACM_2501_Average Speed
- zoj1890 Average Speed
- hdu 2044 2501 一只小蜜蜂#DP#斐波那契#java水大数
- Sicily 2501.算算式
- Sicily 2501. 算算式
- hdu 2501 dp
- 递归及递推问题系列之 Tiling_easy version hdoj 2501
- hdu 2501 Tiling_easy version 递推
- POJ 2501
- POJ-2501(用例能过,但一直WA)
- 递推--HDU 2501Tiling_easy version
- HDU 2501-Tiling_easy version(递推)
- hdu 2501 Tiling_easy version
- SICIly 2501
- hdu 2501 Tiling_easy version