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

1006. Sign In and Sign Out (25)

时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 <iostream>
#include<string.h>
using namespace std;
typedef struct sign_time{
	char id_num[20];
	int hour;
	int minute;
	int second;
} sign_time;
bool compare_time(sign_time const *time_des,sign_time const *time_sour){
	if(time_des->hour>time_sour->hour)
		return true;
	else if(time_des->hour==time_sour->hour&&time_des>time_sour)
		return true;
	else if(time_des->hour==time_sour->hour&&time_des==time_sour)
		return time_des->second>time_sour->second?true:false;
	else
		return false;
}
int main()
{
	int m,i;
	sign_time sign_in_time={"no_name",25,0,0};
	sign_time sign_out_time={"no_name",-1,0,0};
	cin>>m;
	sign_time tmp_in, tmp_out;
	for(i=0;i<m;i++){
		cin>>tmp_in.id_num;
		cin>>tmp_in.hour;
		getchar();
		cin>>tmp_in.minute;
		getchar();
		cin>>tmp_in.second;
		if(compare_time(&sign_in_time,&tmp_in)){
			strcpy(sign_in_time.id_num,tmp_in.id_num);
			sign_in_time.hour=tmp_in.hour;
			sign_in_time.minute=tmp_in.minute;
			sign_in_time.second=tmp_in.second;
		}
		cin>>tmp_out.hour;
		getchar();
		cin>>tmp_out.minute;
		getchar();
		cin>>tmp_out.second;
		if(compare_time(&tmp_out,&sign_out_time)){
			strcpy(sign_out_time.id_num,tmp_in.id_num);
			sign_out_time.hour=tmp_out.hour;
			sign_out_time.minute=tmp_out.minute;
			sign_out_time.second=tmp_out.second;
		}
	}
	cout<<sign_in_time.id_num<<" "<<sign_out_time.id_num<<endl;
	return 0;
}


1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
`GoogleApiClient.SIGN_IN_MODE_OPTIONAL` 是一个 `GoogleApiClient` 类的常量,用于指定 Google Sign-In API 的登录模式。当您在 `GoogleApiClient.Builder.addApi()` 方法中添加 Google Sign-In API 时,可以使用此常量来指定登录模式。该常量表示如果用户没有使用 Google 登录,仍然可以使用应用程序的其他功能。 例如,以下代码将创建一个 `GoogleApiClient` 对象,该对象将使用可选的登录模式连接到 Google Sign-In API: ``` GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .setSignInOptions(new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build()) .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL) .setViewForPopups(findViewById(android.R.id.content)) .setAccountName(null) .enableAutoManage(this, this) .setHandler(new Handler(Looper.getMainLooper())) .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL) .setViewForPopups(findViewById(android.R.id.content)) .build(); Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient).setResultCallback(new ResultCallback<GoogleSignInResult>() { @Override public void onResult(@NonNull GoogleSignInResult googleSignInResult) { if (googleSignInResult.isSuccess()) { // 用户已经登录,处理结果 handleSignInResult(googleSignInResult); } else { // 用户还没有登录或登录已过期,提示用户登录 Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } } }); ``` 在这个示例中,`GoogleApiClient.Builder.addApi()` 方法将 Google Sign-In API 添加到 `GoogleApiClient` 中,使用了 `GoogleApiClient.SIGN_IN_MODE_OPTIONAL` 常量表示可选登录模式。然后,使用 `Auth.GoogleSignInApi.silentSignIn()` 方法以静默方式进行身份验证。如果用户已经登录,则会处理结果。否则,使用 `Auth.GoogleSignInApi.getSignInIntent()` 方法请求用户登录。如果用户选择不登录,仍可以使用应用程序的其他功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值