1006. Sign In and Sign Out (25)-PAT
来源:互联网 发布:网络作家富豪榜2017年 编辑:程序博客网 时间:2024/05/29 01:52
1006. Sign In and Sign Out (25)
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:3CS301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40Sample 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;elsereturn 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;}
- PAT 1006. Sign In and Sign Out
- PAT 1006. Sign In and Sign Out
- 【PAT】1006. Sign In and Sign Out
- PAT-Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)-PAT
- 【PAT】1006. Sign In and Sign Out (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- 【PAT (Advanced Level)】1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- [PAT]1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- pat 1006. Sign In and Sign Out (25)
- [PAT]1006. Sign In and Sign Out (25)
- 职场经验:找好工作跳稳槽 .
- java压缩单个文件
- SIP conference
- 在PBS/Torque系统用qalter命令延长计算运行时间
- GWT添加媒体显示
- 1006. Sign In and Sign Out (25)-PAT
- ASP.NET之5种全局变量!页面间传值方法
- 2013编程之美挑战赛---传话游戏
- jq单击显示隐藏
- 【91xcz*英雄联盟虚空行者卡萨丁xp主题*91xcz】
- Ext之 model,one2many.proxy.validation _____lesson3
- 海外网络电视用户大力推荐—【BETV】新版震撼来袭
- iOS-cocos2d 精灵缩放效果
- 工厂三兄弟之简单工厂模式(二)