P8665 [蓝桥杯 2018 省 A] 航班时间
- 题目
- 代码
- 分析
题目
代码
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>#include <cctype>
using namespace std;
int t;
int check() {int h1, m1, s1, h2, m2, s2, d = 0;scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);if (getchar() == ' ') {scanf("(+%d)", &d);}return d * 60 * 60 * 24 + (h2) * 60 * 60 + (m2) * 60 + s2 - h1 * 60 * 60 - m1 * 60 - s1;
}int main() {cin >> t;while (t--) {int ans = check() + check() >> 1;printf("%02d:%02d:%02d\n", ans / (60 * 60), ans % ( 60 * 60) / 60, ans % 60);}return 0;
}
分析
没什么分析,参考的大佬的^ ^(不会算)大佬解析