HDU-2033 Clock time A+B

See the article on https://dyingdown.github.io/2019/12/20/HDU-2033%20Clock-time-A+B/

Clock time A + B

There are already 10 A + B questions on HDOJ. I believe these questions were once everyone ’s favorite. I hope that this A + B today will bring good luck to everyone. I also hope that this question will evoke everyone’s concerns about ACM Love.

A and B in this topic are not simple integers, but two times. A and B are composed of 3 integers, which represent hours, minutes, and seconds. For example, if A is 34 45 56, it means that the time represented by A is 34 hours, 45 minutes, and 56 seconds.

Input

The input data consists of multiple lines. First is an integer N, which represents the number of test instances, and then N rows of data. Each line has 6 integers AH, AM, AS, BH, BM, BS, which represent the times A and B, respectively. The corresponding hour, minute, and second. The title guarantees that all data is legal.

Output

For each test instance, output A + B. Each output result is also composed of 3 hours, minutes, and seconds. At the same time, the rules of time must be met (that is, the range of minutes and seconds is 0 ~ 59). One line, and all parts can be represented by 32-bit integers.

Sample Input

2
1 2 3 4 5 6
34 45 56 12 23 34

Sample Output

5 7 9
47 9 30

Analysis

Just stimulate the rule of clock time addition.

Code

#include<bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin >> t;
	int a[3], b[3], c[3];
	while(t --) {
		for(int i = 0; i < 3; i ++) cin >> a[i];
		for(int i = 0; i < 3; i ++) {
			cin >> b[i];
			c[i] = a[i] + b[i];
		} 
		for(int i = 2; i >= 1; i --) {
			c[i - 1] += c[i] / 60;
			c[i] %= 60;
		}
		cout << c[0] << " " << c[1] << " " << c[2] << endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值