Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. void printTimeFromSeconds (unsigned x)
  6. {
  7. unsigned h,m,s;
  8. h=x/3600;
  9. x=x-h*3600;
  10. m=x/60;
  11. s=x%60;
  12. printf("%d:",h);
  13.  
  14. if (m<10) printf("0%d:",m);
  15. else printf("%d:",m);
  16.  
  17. if (s<10) printf("0%d ",s);
  18. else printf("%d ",s);
  19. }
  20.  
  21. void getTimes ()
  22. {
  23. unsigned h=0,m=0,s=0;
  24. unsigned winTime=0,actualTime=0,previousTime=0;;
  25.  
  26. scanf("%d:%d:%d",&h,&m,&s);
  27. winTime=h*3600+m*60+s;
  28.  
  29. printTimeFromSeconds(winTime);
  30. putchar('\n');
  31. previousTime=winTime;
  32.  
  33. while (scanf("%d:%d:%d",&h,&m,&s)==3)
  34. {
  35.  
  36. actualTime=h*3600+m*60+s;
  37.  
  38. putchar('+');
  39. printTimeFromSeconds(actualTime-previousTime);
  40. printTimeFromSeconds(actualTime-winTime);
  41. putchar('\n');
  42.  
  43. previousTime=actualTime;
  44. }
  45.  
  46. }
  47. int main()
  48. {
  49. getTimes();
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement