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<iostream>
#include<string.h>
using namespace std;
typedef struct rcd{
char id[];
int hh,mm,ss;
}record;
int isLater(record a, record b){
if(a.hh > b.hh){
return ;
}else if(a.hh == b.hh && a.mm > b.mm){
return ;
}else if(a.hh == b.hh && a.mm == b.mm && a.ss > b.ss){
return ;
}else{
return ;
}
}
int main(){
int M;
record rd1, rd2, temp1, temp2;
rd1.ss = ;
rd1.mm = ;
rd1.hh = ;
rd2.ss = ;
rd2.mm = ;
rd2.hh = ;
scanf("%d", &M);
for(int i = ; i < M; i++){
scanf("%s%d:%d:%d %d:%d:%d", temp1.id, &(temp1.hh), &(temp1.mm), &(temp1.ss), &(temp2.hh), &(temp2.mm), &(temp2.ss));
strcpy(temp2.id, temp1.id);
if(isLater(rd1, temp1)){
strcpy(rd1.id, temp1.id);
rd1 = temp1;
}
if(isLater(temp2, rd2)){
strcpy(rd2.id, temp2.id);
rd2 = temp2;
}
}
printf("%s %s", rd1.id, rd2.id);
cin >> M;
return ;
}

总结:

1、本题主要在于选择合适的数据结构存储每一条信息。

2、scanf函数,%s读取字符串时遇到空格换行符结束(会自动加\0),字符数组不用取地址符。

3、struct 结构体可以直接赋值,但成员中有数组时,还需要单独拷贝。

A1006. Sign In and Sign Out的更多相关文章

  1. 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 co ...

  2. PAT1006:Sign In and Sign Out

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  3. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  4. PTA (Advanced Level) 1006 Sign In and Sign Out

    Sign In and Sign Out At the beginning of every day, the first person who signs in the computer room ...

  5. PAT Sign In and Sign Out[非常简单]

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  6. PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  7. 1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  8. pat1006. Sign In and Sign Out (25)

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  9. pat 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 com ...

  10. PAT甲级——1006 Sign In and Sign Out

    PATA1006 Sign In and Sign Out At the beginning of every day, the first person who signs in the compu ...

随机推荐

  1. Jenkins配置权限管理

    借鉴博客:https://www.cnblogs.com/Eivll0m/p/6734076.html 懒得写了,照上面是配置成功了,弄了权限角色与用户的配置

  2. snv的使用

    1.搭建SVN服务器 (1)直接安装 (2)创建工号,分组,分配权限(图形化界面的直接操作,非图形界面的需要改配置文件conf文件夹下) (3)创建仓库,D:\Repositories\OA:cmd命 ...

  3. qtp10 安装笔记

    windows10系统安装QTP 10 1 QTP10 程序文件夹下,找到“setup”双击它运行安装程序-点击 否 继续安装 2 安装必要组件 3 下一步 选择安装程序目录-安装插件 直到完成安装 ...

  4. loadrunner -vuser

    在每个负载生成器上,安装 remote agent dispatcher(process) 和 loadrunner agent 控制器指示remote agent dispatcher 在load ...

  5. maven配置,jdk1.8

    <!-- 局部jdk配置,pom.xml中 --> <build> <plugins> <plugin> <groupId>org.apac ...

  6. SpringBoot之加载自定义配置文件

    SpringBoot默认加载配置文件名为:application.properties和application.yml,如果需要使用自定义的配置文件,则通过@PropertySource注解指定. J ...

  7. Upload Files In ASP.NET Core 1.0 (Form POST And JQuery Ajax)

    Uploading files is a common requirement in web applications. In ASP.NET Core 1.0 uploading files and ...

  8. 51nod1016

    1016 水仙花数 V2 1 秒 131,072 KB 160 分 6 级题   水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 ...

  9. Android 取消标题栏

    有很多种方法. 但一般多个页面的话,大多会在AndroidManifest.xml文件中设置 那么这里你需要注意了. 第一种: 如果style.xml 的 parent   是 <style n ...

  10. Python中的numpy模块解析

    numpy 1.  创建对象 维度(dimensions):轴 轴的个数:秩(rank) Numpy最重要的一个特点就是其N维数组对象(即ndarray) 创建数组最简单的函数就是用array函数: ...