PAT甲级——A1006 Sign In and Sign Out
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> using namespace std; //很简单,就是找到来的最早的人和回去最晚的人即可
int getTime(string Time)
{
//由于时间时标准输入,所以很好计算
return ((Time[] - '') * + (Time[] - '')) * * +
((Time[] - '') * + (Time[] - '')) * +
(Time[] - '') * + (Time[] - ''); } int main()
{
int M;
cin >> M;
string firstMan, lastMan;
int firstTime, lastTime;
firstTime = * * + ;//24小时多一秒,属于第二天了
lastTime = -;//属于前一天
string No, InTime, OutTime;
for (int i = ; i < M; ++i)
{
cin >> No >> InTime >> OutTime;
if (firstTime > getTime(InTime))
{
firstTime = getTime(InTime);
firstMan = No;
}
if (lastTime < getTime(OutTime))
{
lastTime = getTime(OutTime);
lastMan = No;
}
}
cout << firstMan << " " << lastMan << endl;
return ;
}
PAT甲级——A1006 Sign In and Sign Out的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT 甲级真题题解(1-62)
准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format 模拟输出,注意格式 #include <cstdio> #include <cstring> #in ...
- 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 ...
随机推荐
- 转——调试寄存器 原理与使用:DR0-DR7
下面介绍的知识性信息来自intel IA-32手册(可以在intel的开发手册或者官方网站查到),提示和补充来自学习调试器实现时的总结. 希望能给你带去有用的信息. (DRx对应任意的一个调试寄存器. ...
- 2019-8-16-调试时限制程序使用-CPU-核心数模拟低端设备
title author date CreateTime categories 调试时限制程序使用 CPU 核心数模拟低端设备 lindexi 2019-08-16 16:11:32 +0800 20 ...
- git统计项目中成员代码量
查看git上个人代码量 git log --author="username" --pretty=tformat: --numstat | awk '{ add += $1; su ...
- CSIC_716_20191119【常用模块的用法 subprocess、re、logging、防止自动测试、包的理论】
subprocess模块 可以通过python代码给操作系统终端发送命令,并可以得到返回结果. import subprocess str = input('>>>请输入命令') # ...
- leetcode-50-pow()
题目描述: 方法一: class Solution: def myPow(self, x: float, n: int) -> float: if n<0: x = 1/x return ...
- python3 enum模块
枚举是绑定到唯一的常量值的一组符号名称(成员).在枚举中,成员可以通过身份进行比较,枚举本身可以迭代. 1.Enum模块 该模块定义了四个枚举类,可用于定义唯一的名称和值集:Enum,IntEnum, ...
- day25 模块,sys, logging, json, pickle
Python之路,Day13 = Python基础13 sys模块 sys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0) sy ...
- XAMPP的安装及使用教程
https://blog.csdn.net/qq_36595013/article/details/80373597#3%E9%85%8D%E7%BD%AEapache
- duilib教程之duilib入门简明教程13.复杂控件介绍
首先将本节要介绍的控件全部拖到界面上,并调整好位置,如图: 然后将Name属性改成其他名字, 不能是[控件名+UI+数字]这种,因为这是DuiDesigner默认的名字,它不会实际写 ...
- skyline中大数据量的三维场景刷新速度问题
我们做了一个的类似于TE Pro的桌面系统来代替TE Pro演示我们的大三维场景.我们的三维场景包括100平方公里的全要素场景,有建筑物,地面.小品.部件.植被等.在系统运行后,三维场景刷不起来,速 ...