(C语言)A+B Again

Your task is to Calculate A+B. But this time, both A and B represents a time. For instance, if we define A as 12 12 12, indicating twelve hours twelve minutes and twelve seconds.

输入:

There are multiple test cases. The first line of the input is an integer T (1 ≤ T ≤ 200), indicating the number of test cases. Then T test cases follow.
For each case, each line consists of six integers a1​,a2​,a3​ and b1​,b2​,b3​, separated by a space. The first three integers indicate time A, and the last three integers indicate time B.

输出:

For each test case, output one line containing three integers, indicating A+B. Each output consists of three parts, hour, minute and second. And it should be obey the regulations of time, it means that the number of minute or second should not exceed 60. You should output the sum of A and B in one line.

解决代码如下:

#include <stdio.h>
 
int main()
{
    int a,b,a1,a2,a3,b1,b2,b3;
    int s,f,m;
    b=1;
    scanf("%d",&a);
    while(b<=a){
        scanf("%d%d%d%d%d%d",&a1,&a2,&a3,&b1,&b2,&b3);
        m=a3+b3;
        f=b2+a2;
        s=a1+b1;
        if(m>=60){
            m=m-60;
            f=f+1;
        }
        if(f>=60){
            f=f-60;
            s=s+1;
        }
        printf("%d %d %d\n",s,f,m);
        b++;    
    }
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值