https://www.acwing.com/problem/content/1233/
简简单单小模拟
要注意的是,这题有点类似于脑筋急转弯,需要仔细分析题意,带入假设量计算得出即可
并且此题输入有点毒,可以用getline读入一行,再从string中一个一个的抠出来变量,也可用格式输入
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int hour1,minute1,second1,day1;
int hour2,minute2,second2,day2;
int get_time(int hour,int minute,int second,int day)
{
return hour*3600+minute*60+second+day*24*3600;
}
void turn(int second)
{
int h=second/3600;
int m=second%3600/60;
int s=second%3600%60;
printf("%02d:%02d:%02d\n",h,m,s);
}
int main()
{
cin >> n;
while(n--)
{
int tmp=0;
for(int i=0;i<2;i++)
{
day1=day2=0;
scanf("%d:%d:%d (+%d)", &hour1,&minute1,&second1,&day1);
scanf("%d:%d:%d (+%d)", &hour2,&minute2,&second2,&day2);
tmp+=get_time(hour2,minute2,second2,day2)-get_time(hour1,minute1,second1,day1);
}
tmp/=2;
turn(tmp);
}
return 0;
}
标签:02d,3600,1231,int,60,航班,second,时间,second% From: https://www.cnblogs.com/lxl-233/p/16786601.html