Advertisement
erfanul007

UVa 10281

Nov 10th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. long long int h,m,s,v,sec,prs=0,dif,vel=0;
  5. double dis=0,tan;
  6. char c;
  7. while(scanf("%lld:%lld:%lld%c",&h,&m,&s,&c)!=EOF){
  8. if(c=='\n'){
  9. sec=(h*3600)+(m*60)+s;
  10. dif=sec-prs;
  11. tan=(vel*dif)/(double)3600;
  12. dis=dis+tan;
  13. printf("%02lld:%02lld:%02lld %.2lf km\n",h,m,s,dis);
  14. prs=sec;
  15.  
  16. }
  17. else if(c==' '){
  18. sec=(h*3600)+(m*60)+s;
  19. dif=sec-prs;
  20. tan=(vel*dif)/(double)3600;
  21. dis=dis+tan;
  22. scanf("%lld",&v);
  23. vel=v;
  24. prs=sec;
  25. }
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement