George and Sleep
2016-01-03 17:20
357 查看
Description
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time
t.
Help George! Write a program that will, given time s and
t, determine the time
p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).
Input
The first line contains current time s as a string in the format "hh:mm". The second line contains time
t in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is,
00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.
Output
In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.
Sample Input
Input
Output
Input
Output
Input
Output
Hint
In the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06",
"00:6" and others will be considered incorrect.
In the second sample, George went to bed yesterday.
In the third sample, George didn't do to bed at all.
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time
t.
Help George! Write a program that will, given time s and
t, determine the time
p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).
Input
The first line contains current time s as a string in the format "hh:mm". The second line contains time
t in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is,
00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.
Output
In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.
Sample Input
Input
05:50 05:44
Output
00:06
Input
00:00 01:00
Output
23:00
Input
00:01 00:00
Output
00:01
Hint
In the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06",
"00:6" and others will be considered incorrect.
In the second sample, George went to bed yesterday.
In the third sample, George didn't do to bed at all.
#include<cstdio> #include<iostream> using namespace std; int main(){ int hh,nn,gg,mm; while(~scanf("%d:%d",&hh,&nn)){ scanf("%d:%d",&gg,&mm); nn-=mm; if(nn<0){ nn+=60; hh--; } hh-=gg; if(hh<0){ hh+=24; } printf("%02d:%02d\n",hh,nn); } return 0; }
相关文章推荐
- view的封装,xib和stroryBoard加载及使用
- 学过JDBC才知道前一篇文章的经历完全可以避免。。。
- CentOS7中自编的一个支持suid的system函数(c语言)
- Python—装饰器
- String类之indexOf--->查找某字对应的位置
- FPGA笔记 AS和JTAG下载方式区别
- java学习细节知识点总结
- java中开发工具版本不对造成的后果之一
- [Leetcode]3. Longest Substring Without Repeating Characters
- 2015前端生态发展回顾
- 谷歌网站
- Apache实现禁止中文浏览器访问与301重定向的方法
- [leetcode] 11. Container With Most Water 解题报告
- UI组件的呈现
- 笔试题中 3种错误处理的方法
- QUESTION 47 How many copies of the alert log are stored in the directory specified by the initializa
- uva 1557 - Calendar Game(博弈)
- 瞠目结舌的JavaScript技巧
- MyEclipse常见的异常总结
- 远处的是风景,近处的才是人生