A. George and Sleep
来源:互联网 发布:智能电视软件市场 编辑:程序博客网 时间:2024/05/21 17:24
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).
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.
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.
05:5005:44
00:06
00:0001:00
23:00
00:0100:00
00:01
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.
题意: 输入两个时间,第一个表示醒来时的时间,第二个表示刚睡觉时候的时间,求睡了多长时间
#include<iostream>#include <cstring>#include <algorithm>#include <cstdio>#include <iomanip>#include <cmath>using namespace std;int main(){ int h1,m1,h2,m2; while(scanf("%d:%d\n%d:%d",&h1,&m1,&h2,&m2)!=EOF) { int t=h1*60+m1-h2*60-m2; if(t<0) t+=24*60; cout<<setw(2)<<setfill('0')<<t/60<<":"<<setw(2)<<setfill('0')<<t%60<<endl; } return 0;}
- A. George and Sleep
- A. George and Sleep
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- Codeforces 387A George and Sleep
- George and Sleep
- . George and Sleep
- codeforces George and Sleep
- George and Sleep
- George and Sleep
- Codeforces Round #227 (Div. 2)A. George and Sleep
- Codefoces 387A George and Sleep(水题)
- Codeforces Round #227 (Div. 2)---A. George and Sleep
- A. George and Accommodation
- 467A. George and Accommodation
- 467A - George and Accommodation
- Codeforces 467A George and Accommodation
- 三周 项目3 完整版
- 数据分页存储过程
- NoSQL 数据库汇总
- 网上常用免费WebServices集合
- Hdu 3339 In Action[最短路+01背包]
- A. George and Sleep
- 网站优化不得不注意的问题
- 在Oracle中查询包含某列的表名
- POJ:2828 Buy Tickets(线段树)
- VMware ESXi中Windows Server 2008 R2虚拟机每隔1小时自动重启
- 详解qt路径-从 相对路径 说开来(从C++到Qt) .
- 二叉树的遍历(前序、中序、后序、层序),递归和非递归实现
- hadoop中的一些基本操作及wordcount的运行操作示范
- 网页设计必知:什么是CSS?它的能做些什么?