AcWing 1231. 航班时间
原题链接
简单
作者:
ycqs
,
2021-04-09 19:51:18
,
所有人可见
,
阅读 365
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int n;
string s1,s2;
cin>>n;
cin.ignore(1024,'\n');
for(int i=0;i<n;i++){
getline(cin,s1);
getline(cin,s2);
int t1,t2;
t1=stoi(s1.substr(15,2))+stoi(s1.substr(12,2))*60+
stoi(s1.substr(9,2))*3600-stoi(s1.substr(6,2))-
stoi(s1.substr(3,2))*60-stoi(s1.substr(0,2))*3600;
t2=stoi(s2.substr(15,2))+stoi(s2.substr(12,2))*60+
stoi(s2.substr(9,2))*3600-stoi(s2.substr(6,2))-
stoi(s2.substr(3,2))*60-stoi(s2.substr(0,2))*3600;
if(s1.size()>18)t1+=stoi(s1.substr(20,1))*3600*24;
if(s2.size()>18)t2+=stoi(s2.substr(20,1))*3600*24;
printf("%02d:%02d:%02d\n",(t1+t2)/2/3600,(t1+t2)/2%3600/60,(t1+t2)/2%60);
}
return 0;
}