Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long int h,m,s,v,sec,prs=0,dif,vel=0;
- double dis=0,tan;
- char c;
- while(scanf("%lld:%lld:%lld%c",&h,&m,&s,&c)!=EOF){
- if(c=='\n'){
- sec=(h*3600)+(m*60)+s;
- dif=sec-prs;
- tan=(vel*dif)/(double)3600;
- dis=dis+tan;
- printf("%02lld:%02lld:%02lld %.2lf km\n",h,m,s,dis);
- prs=sec;
- }
- else if(c==' '){
- sec=(h*3600)+(m*60)+s;
- dif=sec-prs;
- tan=(vel*dif)/(double)3600;
- dis=dis+tan;
- scanf("%lld",&v);
- vel=v;
- prs=sec;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement