-
-
#include<iostream>
-
usingnamespacestd;
-
intmain()
- {
-
freopen("in.txt","r",stdin);
-
inth,m,s,k(0);
-
intpres(0),nows,time;
-
doublesum=0.0;
-
charc;
-
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.2lfkm\n",sum);
- }
- pres=s+m*60+h*60*60;
- }
-
return0;
- }
关键是输出格式的处理,还又要注意 24小时变为0小时