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. laravel中如何在模型中自关联?

    https://segmentfault.com/q/1010000007926567 在模型中声明一对多的关系,关联表本身.parent_id对应父记录的id.我在sof中查阅到很多这样的写法: p ...

  2. .Net在操作mysql查询的时候出现“: Unknown column 'UserName' in 'where clause'”错误

    今天使用.Net操作mysql查询的时候,如果加上条件查询的时候就会出现 Unknown column 'UserName' in 'where clause'这个错,不加条件直接select * f ...

  3. CLOUD不审核修改物料

  4. 保存后自动格式化代码(vscode)

    痛点: 写项目的时候, 我们经常会拷贝一些代码, 每当拷贝过来都需要重新调整, 如果可以实现保存自动调整代码, 将会给我们带来很多的便利! 解决: 其实对于vscode来说, 实现这一点很容易. 我们 ...

  5. Android——Activity的简绍

    Activity Activity的运行机制其实和JavaEE中的servlet很像,而我们的Android系统也就相当与其servlet容器,Activity在其中进行创建实例.初始化.运行.销毁等 ...

  6. Python:matplotlib绘制散点图

    与线型图类似的是,散点图也是一个个点集构成的.但不同之处在于,散点图的各点之间不会按照前后关系以线条连接起来. 用plt.plot画散点图     奇怪,代码和前面的例子差不多,为什么这里显示的却是散 ...

  7. Google浏览器解决编码乱码问题

    新版google浏览器编码乱码没有设置的入口,怎么办呢?. 步骤一: 可以下载goole的插件,名为charset,下载后的文件名为Charset_v0.4.1 步骤二: google右上角-> ...

  8. 当对具体的一条记录进行操作时候 需要传递该记录的id

  9. iOS后台运行播放无声音频 测试可行

    如果打回来了,就自认倒霉吧 制作无声音频. @interface AppDelegate () { NSInteger count; } @property(strong, nonatomic)NST ...

  10. UESTC1013-我的魔法栈-模拟/排列组合

    有一个串,有黑色和白色两种元素.一次操作可以把最上面的白色元素变成黑色,同时把这个元素上面的所有元素变成白色. 给你一个30以内的串,计算变成全黑时,元素变化的总和. 我用的方法比较笨,打表处理了1- ...