#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
int n;
int AH, AM, AS, BH, BM, BS;
int sh, sm, ss;
while (cin >> n)
{
while (n--)
{
cin >> AH >> AM >> AS >> BH >> BM >> BS;
sh = 0; sm = 0; ss = 0;
ss = AS + BS;
if (ss > 59)
{
++sm; ss -= 60;
}
sm += AM + BM;
if (sm > 59)
{
++sh;
sm -= 60;
}
sh += AH + BH;
cout << sh << " " << sm << " " << ss << endl;
}
}
return 0;
}
#include <string>
#include<math.h>
using namespace std;
int main()
{
int n;
int AH, AM, AS, BH, BM, BS;
int sh, sm, ss;
while (cin >> n)
{
while (n--)
{
cin >> AH >> AM >> AS >> BH >> BM >> BS;
sh = 0; sm = 0; ss = 0;
ss = AS + BS;
if (ss > 59)
{
++sm; ss -= 60;
}
sm += AM + BM;
if (sm > 59)
{
++sh;
sm -= 60;
}
sh += AH + BH;
cout << sh << " " << sm << " " << ss << endl;
}
}
return 0;
}
该程序通过输入两个时间点,计算并输出这两个时间点之间的总时间。采用C++编写,能够处理跨过小时的时间相加问题,并自动调整分钟和秒数。
518

被折叠的 条评论
为什么被折叠?



