#include<iostream>
#include<cstring>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string a, b, c, d, e, f;
int t1 = 0, t2 = 0;
cin >> a >> b;
if (getchar() == ' ') {
cin >> e;
if (e[2] == '1') t1 += 24 * 3600;
else if (e[2] == '2') t1 += 48 * 3600;
}
cin >> c >> d;
if (getchar() == ' ') {
cin >> f;
if (f[2] == '1') t2 += 24 * 3600;
else if (f[2] == '2') t2 += 48 * 3600;
}
int time, hour, min, second;
t1 += 3600 * ((b[0] - '0') * 10 + (b[1] - '0'))
+ 60 * ((b[3] - '0') * 10 + (b[4] - '0'))
+ (b[6] - '0') * 10 + (b[7] - '0')
- (3600 * ((a[0] - '0') * 10 + (a[1] - '0')))
- (60 * ((a[3] - '0') * 10 + (a[4] - '0')))
- ((a[6] - '0') * 10 + (a[7] - '0'));
t2 += 3600 * ((d[0] - '0') * 10 + (d[1] - '0'))
+ 60 * ((d[3] - '0') * 10 + (d[4] - '0'))
+ (d[6] - '0') * 10 + (d[7] - '0')
- (3600 * ((c[0] - '0') * 10 + (c[1] - '0')))
- (60 * ((c[3] - '0') * 10 + (c[4] - '0')))
- ((c[6] - '0') * 10 + (c[7] - '0'));
time = (t1 + t2) / 2;
hour = time / 3600;
time %= 3600;
min = time / 60;
time %= 60;
second = time;
printf("%02d:%02d:%02d\n", hour, min, second);
}
return 0;
}
每日一题洛谷P8665 [蓝桥杯 2018 省 A] 航班时间c++
最新推荐文章于 2025-05-29 23:36:29 发布