Advertisement
Saleh127

Untitled

Apr 29th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. char x[128];
  6. int a,h,m,s,t=0,t1 = 0;
  7. double dis = 0.0,v=0.0,v1=0.0;
  8.  
  9. while ( gets(x) )
  10. {
  11. a = sscanf(x,"%d:%d:%d %lf",&h,&m,&s,&v1);
  12.  
  13. t1 = h*3600+m*60+s;
  14.  
  15. dis += v*(t1-t)/3600.0;
  16.  
  17. t = t1;
  18.  
  19. if (a == 3 )
  20. printf("%.2d:%.2d:%.2d %.2lf km\n",h,m,s,dis);
  21. else
  22. v = v1;
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement