【暑期基础2】H HDU 2033 人见人爱A+B

来源:互联网 发布:js中九九乘法表 编辑:程序博客网 时间:2024/04/27 21:55

题意

给出两个时间,求这两个时间相加的和。


思路

只需注意 60 进制进位即可。(进位:carry)


AC 代码 *

#include <stdio.h>#include <ctype.h>#include <string.h>int main() {    int n;    int ah, am, as, bh, bm, bs;    int h, m, s;    int h_carry, m_carry;    scanf("%d\n", &n);    while ( n-- ) {        scanf("%d %d %d %d %d %d", &ah, &am, &as, &bh, &bm, &bs);        m_carry = ( as + bs ) / 60;        s = ( as + bs ) % 60;        h_carry = ( am + bm + m_carry ) / 60;        m = ( am + bm + m_carry ) % 60;        h = ah + bh + h_carry;        printf("%d %d %d\n", h, m, s);    }    return 0;}

* 注:在 HUST 的 Virtual Judge 上测试 AC

0 0