`
风吹过PP好冷
  • 浏览: 36430 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

PAT1006 Sign In and Sign Out

    博客分类:
  • PAT
 
阅读更多

请根据记录找出当天开门和关门的人。

 

Sample Input:

3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
Sample Output:
SC3021234 CS301133

 

 

 

 

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int M;
	cin>>M;
	int Entertime = -1;
	int Leavetime = -1;
	string EnterID,LeaveID;
	while (M--)
	{
		string str;
		int t1,t2,t3,t4,t5,t6;
		char c;
		cin>>str>>t1>>c>>t2>>c>>t3>>t4>>c>>t5>>c>>t6;
		int time1 = t1*3600 + t2*60 + t3;
		int time2 = t4*3600 + t5*60 + t6;

		if (time1 < Entertime || Entertime == -1)
		{
			EnterID = str;
			Entertime = time1;
		}

		if (time2 > Leavetime || Leavetime == -1)
		{
			LeaveID = str;
			Leavetime = time2;
		}

	}
	cout<<EnterID<<" "<<LeaveID;
	return 0;
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics