答案:
#include <stdio.h>
void time(int ah, int am, int as, int bh, int bm, int bs, int* sum_h, int* sum_m, int* sum_s) //不需要返回值所以定义void函数,前面6个为输入,然后用指针存给后面三个
{*sum_s = (as + bs) % 60; //相加后的秒数int add = (as + bs) / 60; //满60秒进1*sum_m = (am + bm + add) % 60; //相加后的分钟add = (am + bm + add) / 60; //满60分进1*sum_h = ah + bh + add; //总小时数
}int main()
{int n = 0;scanf("%d", &n);while (n--) //循环n次{int ah = 0, am = 0, as = 0, bh = 0, bm = 0, bs = 0;scanf("%d%d%d%d%d%d", &ah, &am, &as, &bh, &bm, &bs); //输入数据int sum_h = 0, sum_m = 0, sum_s = 0;time(ah, am, as, bh, bm, bs, &sum_h, &sum_m, &sum_s);printf("%d %d %d\n", sum_h, sum_m, sum_s); //打印总时间}return 0;
}