- /*
- 第一行的速度可能为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;
- }
2501 Average Speed
最新推荐文章于 2022-02-25 19:38:17 发布