Cute A + B
Subject description:
HDOJ above has 10 channels A + B of the subject, I believe that these problems used to be everyone's favorite, the hope that today's A + B we can bring good luck, and hope that this subject rouses once told the ACM love.
A and B of the subject is not a simple integer, but two time, A and B are composed of three integers, respectively, minutes and seconds, for example, is assumed A 344 556, it means that the time represented by A 34 hours 45 minutes 56 seconds.Input
Multiple rows of input data, a first integer N, the number of test cases, and then the data of N rows, each row having six integers AH, AM, AS, BH, BM, BS, A and B denote time when the corresponding Minutes. Topic ensure that all data is valid.
Output
For each test case, the output of A + B, the result is output for each section 3 minutes and seconds from the composition, but also time rule is satisfied (ie: second points and in the range of 0 to 59), each output representing line, and all the parts can be represented by 32-bit integer.
Sample Input
2 1 2 3 4 5 6 34 45 56 12 23 34Sample Output
5 7 9 47 9 30
By the answer:
#include <stdio.h>
int main() {
int n,Ah,Am,As,Bh,Bm,Bs;
int sum1,sum2,sum3;
while (scanf("%d\n", &n)!=EOF) {
while(n--){
scanf("%d %d %d %d %d %d",&Ah,&Am,&As,&Bh,&Bm,&Bs);
sum1=Ah+Bh;
sum2=Am+Bm;
sum3=As+Bs;
if(sum3>=60){ //若满60,则进1
sum2++;
sum3-=60;
}
if(sum2>=60){
sum1++;
sum2-=60;
}
printf("%d %d %d\n",sum1,sum2,sum3);
}
}
return 0;
}