#include <iostream>
#include "stdio.h"
#include "string"
using namespace std;
class Time
{
public://注意这里要声明PUBLIC
Time(){}
int h,m,s;
bool operator <(Time &a)//运算符重载,还有一种格式是友元函数重载
{
if(a.h==h&&a.m==m) return s<a.s;
else if(a.h==h) return m<a.m;
else return h<a.h;
}
};
class peo//每个人都有一个ID以及一个来和离开的时间
{
public:
char id[30];
Time t1,t2;
};
void Equal(Time src,Time des)
{
des.h=src.h,des.m=src.m,des.s=src.s;
}
int main()
{ int n,m;
cin>>n;
while (n--)
{
cin>>m;
char id1[30],id2[30];
Time minn,maxx;
scanf("%s %d:%d:%d %d:%d:%d",&id1,&minn.h,&minn.m,&minn.s,&maxx.h,&maxx.m,&maxx.s);
strcpy(id2,id1);//只有一个人的情况,开门关门为同一个人
while(--m)
{
peo p;
scanf("%s %d:%d:%d %d:%d:%d",&p.id,&p.t1.h,&p.t1.m,&p.t1.s,&p.t2.h,&p.t2.m,&p.t2.s);
if (p.t1<minn)
{
Equal(minn,p.t1);
strcpy(id1,p.id);
}
if (maxx<p.t2)
{
Equal(maxx,p.t2);
strcpy(id2,p.id);
}
}
cout<<id1<<" "<<id2<<endl;
}
system("pause");
}
开门关门
最新推荐文章于 2022-08-07 12:09:21 发布