1006. Sign In and Sign Out (25)

原创 2015年11月21日 19:29:03

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day.

Input Specification:

Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:

ID_number Sign_in_time Sign_out_time

where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.

Output Specification:

For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.

Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.

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<cstdio>
#include<cstdlib>
#include<cstring>

char earliesttime[9] = "23:59:59";
char latesttime[9] = "00:00:00";

char earliestman[16];
char latestman[16];

char inputID[16];
char inputSignin[9];
char inputSignout[9];

int main(void)
{
	int M;
	scanf("%d",&M);
	for(int i = 0;i<M;++i)
	{
		scanf("%s %s %s",inputID,inputSignin,inputSignout);
		if(strcmp(inputSignin,earliesttime) < 0)
		{
			strcpy(earliesttime,inputSignin);
			strcpy(earliestman,inputID);
		}
		if(strcmp(inputSignout,latesttime) > 0)
		{
			strcpy(latesttime,inputSignout);
			strcpy(latestman,inputID);
		}
	}
	printf("%s %s",earliestman,latestman);
	system("pause");
	return 0;
}


版权声明:本文为jungleni原创文章,转载请注明出处。

1006. Sign In and Sign Out (25)解题思路

1006. Sign In and Sign Out (25)解题思路目录Sign In and Sign Out 25解题思路 目录 原题 解题思路 复杂度分析 code原题 At the be...
  • chr1991
  • chr1991
  • 2016年06月25日 07:28
  • 662

PAT (Advanced Level) Practise 1006 Sign In and Sign Out (25)

1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 1...
  • jtjy568805874
  • jtjy568805874
  • 2016年03月02日 19:41
  • 409

1006. Sign In and Sign Out (25)u

pat, 这题相对于简单点,主要就是根据时间排序,然后找出最先来和最后走的同学学号。 解题心得: 1、对c++stl库中的sort函数熟悉了一把,会使用了。 2、以00:00:00作为起点来比...
  • anLA_
  • anLA_
  • 2017年01月05日 00:15
  • 323

PAT-Java-1006-Sign In and Sign Out (25)

1006. Sign In and Sign Out 题目阐述 At the beginning of every day, the first person who signs in th...
  • rebornyp
  • rebornyp
  • 2018年01月13日 16:18
  • 39

**1006. Sign In and Sign Out (25)**

1006. Sign In and Sign Out (25)At the beginning of every day, the first person who signs in the comp...
  • FEATHER2016
  • FEATHER2016
  • 2017年11月15日 09:52
  • 86

1006. Sign In and Sign Out (25)

1006. Sign In and Sign Out (25) #include #include class A { public: enum{timelen=9,idlen=16};...
  • gk2007310201668
  • gk2007310201668
  • 2013年11月12日 17:10
  • 650

1006. Sign In and Sign Out (25)?

#include #include #include"string.h" int main() { char minID[18]; char maxID[18]; cha...
  • sanyuenanfang
  • sanyuenanfang
  • 2016年11月21日 10:48
  • 103

浙大PAT 1006题 1006. Sign In and Sign Out

#include #include int main(){ int i,j,k,n,len; char intime[10]={"23:59:59"},outtime[10]={"00:00:...
  • Sup_Heaven
  • Sup_Heaven
  • 2012年12月29日 21:38
  • 1267

Python实现Pat 1006. Sign In and Sign Out (25)

Pat 1006. Sign In and Sign Out (25)At the beginning of every day, the first person who signs in the ...
  • YCHANTY
  • YCHANTY
  • 2017年06月24日 23:04
  • 103

1006. Sign In and Sign Out

题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1006 开门人关门人,时间是可以按字符串直接比较的,直接排序。 // sort #incl...
  • Staibin
  • Staibin
  • 2014年03月13日 22:47
  • 411
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:1006. Sign In and Sign Out (25)
举报原因:
原因补充:

(最多只允许输入30个字)