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
题目分析:给定数据排序 ,直接利用vector对结构体排序 将比较函数重写就可以了
注意sort中比较函数 返回true是不交换的 鉴于现在我水平较低 之后会尝试分析 源码的(大概
 #include<iostream>
#include<string>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std;
#define MaxNum 1
typedef struct Node {
string ID_numebr;
string Sign_in_time;
string Sign_out_time;
}S;
typedef struct Time {
int H;
int M;
int S;
}T;
T t1, t2;
int Atoi(string str, int i, int j)
{
int num = ;
while (i<j)
{
num = num * + str[i] - '';
i++;
}
return num;
}
bool comp2(const S& a, const S& b)
{ t1.H = Atoi(a.Sign_out_time, , );
t1.M = Atoi(a.Sign_out_time, , );
t1.S = Atoi(a.Sign_out_time, , );
t2.H = Atoi(b.Sign_out_time, , );
t2.M = Atoi(b.Sign_out_time, , );
t2.S = Atoi(b.Sign_out_time, , );
if (t1.H > t2.H)
return true;
else if (t1.H == t2.H && t1.M > t2.M)
return true;
else if (t1.M == t2.M && t1.S > t2.S)
return true;
else
return false;
} bool comp1(const S& a, const S& b)
{ t1.H = Atoi(a.Sign_in_time, , );
t1.M = Atoi(a.Sign_in_time, , );
t1.S = Atoi(a.Sign_in_time, , );
t2.H = Atoi(b.Sign_in_time, , );
t2.M = Atoi(b.Sign_in_time, , );
t2.S = Atoi(b.Sign_in_time, , );
if (t1.H < t2.H)
return true;
else if (t1.H == t2.H && t1.M < t2.M)
return true;
else if (t1.M == t2.M && t1.S < t2.S)
return true;
else
return false;
} int main()
{
vector<Node> N;
S s;
int n;
cin >> n;
for (int i = ; i < n; i++)
{
cin >> s.ID_numebr >> s.Sign_in_time >> s.Sign_out_time;
N.push_back(s);
}
sort(N.begin(), N.end(), comp1);
cout << N[].ID_numebr<<" ";
sort(N.begin(), N.end(), comp2);
cout << N[].ID_numebr;
return ;
}

1006 Sign In and Sign Out (25 分)的更多相关文章

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

  2. 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 ...

  3. 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. 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 ...

  5. PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642 题目描述: At the beginning of ever ...

  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. pat1006. Sign In and Sign Out (25)

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

  8. 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 ...

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

  10. 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 ...

随机推荐

  1. 分布式图数据库 Nebula Graph 的 Index 实践

    导读 索引是数据库系统中不可或缺的一个功能,数据库索引好比是书的目录,能加快数据库的查询速度,其实质是数据库管理系统中一个排序的数据结构.不同的数据库系统有不同的排序结构,目前常见的索引实现类型如 B ...

  2. 通过mockjs来制作假数据

    需用用到的模块为express和mockjs //导入模块开启服务器模块 const express=require('express') //导入假数据模块 const mockjs=require ...

  3. Android 版的多合一Office应用也正式向iOS开放了

    导读 在 Android 版的多合一 Office 应用「偷跑」不久后(官方证实上线时间比计划要早),为 iOS 准备的版本现在终于也结束 beta 测试正式上线了. 和只提供「有限」平板支持的 An ...

  4. Android平台接入OneNET

    1. OneNET简介 中国移动物联网开放平台是由中国移动打造的PaaS物联网开放平台. 平台能够帮助开发者轻松实现设备接入与设备连接,提供综合性的物联网解决方案,实现物联网设备的数据获取,数据存储, ...

  5. (转)bss段和.data的是是非非

    原文地址:http://zqwt.012.blog.163.com/blog/static/12044684201101214457186/ 一般情况下,一个程序本质上都是由 bss段.data段.t ...

  6. C/C++、C#、JAVA(一):代码模板与库代码的引入

    代码默认模板 编译性高级编程语言中,几乎每种语言,都有个静态的 main 方法作为程序启动入口,每种语言都有其编写规范.为了学习 C/C++.C#.JAVA四种语言,我们要先从默认代码模板中,慢慢摸索 ...

  7. JAVA 转换 树结构数据

    JAVA 转换 树结构数据 第一步:引入fastjson <dependency> <groupId>com.alibaba</groupId> <artif ...

  8. VS2019 C++动态链接库的创建使用(3) - 如何导出类

    如何在动态链接库里导出一个类? ①在库头文件里增加一个类声明,class DLL1_API Point是将类内所有成员都导出,如果只导出某个成员函数,则只需在对应的成员函数前加DLL1_API即可: ...

  9. VS2019 C++动态链接库的创建使用(2) - 客户调用接口

    因为动态链接库里的内容是自己定义的,所以在外部程序调用时我们自己知道库里包含哪些变量和函数,如果我们提供库给其他人使用,则最好增加一个头文件,告知库里包含的函数: ①将动态链接库源文件内容增加红色框内 ...

  10. [Docker8]Dockerfiles

    Comment INSTRUCTION arguments FROM 基于哪个base镜像 RUN 执行命令并创建新的镜像层,run经常用于安装软件包 MAINTAINER 镜像创建者 copy 将文 ...