点击跳转例题
思路:去的飞行时间为:起降时间差+k(时差)----t1回来的飞行时间位: 起降时间差 - k(时差)---t2
所以飞行时间是就是(t1+t2)/2;
注意事项:所以都换算成秒计算。注意输入,标点符号多的情况下用scanf;
代码:
#include <bits/stdc++.h> using namespace std; int f() { 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*86400+h2*3600+m2*60+s2)-(h1*3600+m1*60+s1); } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; scanf("%d",&t); while(t--) { int ans=(f()+f())/2; printf("%02d:%02d:%02d\n",ans/3600,ans%3600/60,ans%60); } return 0; }
P8665 [蓝桥杯 2018 省 A] 航班时间--2024蓝桥杯冲刺省一
最新推荐文章于 2024-03-21 17:41:27 发布