https://blog.csdn.net/weixin_43914593/article/details/112728088
(1) Calculation
of flight time Suppose take-off time is S, arrival time is T, one-way flight time is X, and time difference is T.
From A to B: S1 + X + T = E1
from B to A: XT = Sl + E2 of
☀ two finishing of formula obtained: 2X = (E1-S1) + (E2-S1), the answer is X.
☀☀☀It can be seen that there is no need to calculate the time difference T, because one goes and one time, they cancel each other out.
(It is very easy to directly convert it to S when calculating the time!!!)
(2) Input and output
It is the easiest to use scanf in C language for input
Since the output needs to be filled with 0, C language printf must be used to control the formatted output
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn = 110000;
int get_time()
{
int h1,h2,m1,m2,s1,s2;
scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
int day=0;
if((getchar())!=0)
scanf("(+%d)",&day);
int S=h1*3600+m1*60+s1;
int E=h2*3600+m2*60+s2;
return E-S+day*24*3600;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int ans=(get_time()+get_time())/2;
printf("%02d:%02d:%02d\n",ans/3600,ans/60%60,ans%60);
}
return 0;
}