题目:https://www.patest.cn/contests/pat-a-practise/1006
代码:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct per{
char id[16];
int h,m,s;
}temp,late,early;
bool later(per a,per b)
{
if(a.h!=b.h) return a.h>b.h;
if(a.m!=b.m) return a.m>b.m;
return a.s>b.s;
}
int main()
{
int m;
scanf("%d",&m);
early.h=24,early.m=60,early.s=60;
late.h=0,late.m=0,late.s=0;
while(m--)
{
scanf("%s %d:%d:%d",&temp.id,&temp.h,&temp.m,&temp.s);
if(later(temp,early)==false) early =temp;
scanf("%d:%d:%d",&temp.h,&temp.m,&temp.s);
if(later(temp,late)==true) late=temp;
}
printf("%s %s",early.id,late.id);
system("pause");
}