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;
}