codeforces 622B B. The Time
1 second
256 megabytes
standard input
standard output
You are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.
Note that you should find only the time after a minutes, see the examples to clarify the problem statement.
You can read more about 24-hour format here https://en.wikipedia.org/wiki/24-hour_clock.
The first line contains the current time in the format hh:mm (0 ≤ hh < 24, 0 ≤ mm < 60). The hours and the minutes are given with two digits (the hours or the minutes less than 10 are given with the leading zeroes).
The second line contains integer a (0 ≤ a ≤ 104) — the number of the minutes passed.
The only line should contain the time after a minutes in the format described in the input. Note that you should print exactly two digits for the hours and the minutes (add leading zeroes to the numbers if needed).
See the examples to check the input/output format.
23:59
10
00:09
20:20
121
22:21
10:10
0
10:10
题意:问从起点时间经过所给的时间,终点时间是多少;
思路:将时间都转换成分钟;
AC代码:
#include <bits/stdc++.h>
using namespace std;
char str[8];
int a;
int main()
{
scanf("%s",str);
scanf("%d",&a);
int x1,x2;
x1=(str[0]-'0')*10+(str[1]-'0');
x2=(str[3]-'0')*10+(str[4]-'0');
//cout<<x1<<":"<<x2<<"\n";
x2+=a;
x1+=x2/60;
x2%=60;
x1%=24;
if(x1<10)printf("0%d:",x1);
else printf("%d:",x1);
if(x2<10)printf("0%d\n",x2);
else printf("%d\n",x2);
return 0;
}
最新文章
- hexo+github搭建个人博客
- 如何在Ubuntu上配置scala教程
- 从零开始写一个武侠冒险游戏-7-用GPU提升性能(2)
- javascript中json解密
- Ubuntu 安装 Brother MFC7470D 驱动
- Android --slidedatetimepicker时间控件应用
- ssh 命令
- MyEclipse各种操作
- hdu 4099 Revenge of Fibonacci 大数+压位+trie
- telnet简单操作 模拟请求
- android textview 行间距
- android中ScrollView和GridView/ListView共存时,ScrollView不在顶部的解决方法
- 不直接访问远程的数据库,而是通过中间件(专业DBA的博客)
- 15个最好的HTML5前端响应式框架(2014)
- JS 高效快速的数组去重
- viewpager处理(二):设置当前item时,让viewpager不出现滑动动画
- Java面试07|Redis数据库
- RxJS操作符(三)
- Linux-3.0.8 input subsystem代码阅读笔记
- git从其他分支提取文件merge到当前分支