航班时间
时区是人定的,飞机是活的,它在飞,但地球也再转,
所以等于飞机飞完以后,还要逆行飞,这样把问题就抽象出来了
又因为飞机来回飞行时间相同,所以输入并操作两次然后t/2即可
#include<iostream>
#include<cstdio>
using namespace std;
int get_time()
{
string line;
getline(cin,line);
if(line[line.size() - 1] != ')') line += " (+0)";
int h1,m1,s1,h2,m2,s2,d;
sscanf(line.c_str(),"%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1, &h2, &m2, &s2, &d);
return 3600*h2+60*m2+s2-3600*h1-60*m1-s1+d*24*3600;
}
int main()
{
int t;
scanf("%d",&t);
getchar();
while(t --)
{
int time = (get_time() + get_time())/2;
int hour=time/3600,minute=time%3600/60,second=time%60;
printf("%02d:%02d:%02d\n",hour,minute,second);
}
return 0;
}
要是不会用cpp操作咋整?那直接上纯C
#include<stdio.h>
int getTime(void)
{
int h1,m1,s1,h2,m2,s2,d=0;
scanf("%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1,&h2,&m2,&s2,&d);
int time=d*24*3600+h2*3600+m2*60+s2-(h1*3600+m1*60+s1);
return time;
}
int main()
{
int t;
scanf("%d",&t);
for(int i = 0; i < t; i++)
{
int time1=getTime();
int time2=getTime();
int t=(time1+time2)/2;
printf("%02d:%02d:%02d\n", t/3600, t/60%60, t%60);
}
return 0;
}