开门关门

#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");
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值