写在前面
实现思路
测试用例
input:
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
output:
ac代码
#include <iostream>
#include <climits>
using namespace std;
int main()
{
int n, minn = INT_MAX, maxn = INT_MIN;
scanf("%d", &n);
string unlocked, locked;
for(int i=0; i<n; i++)
{
string t;
cin >> t;
int h1, m1, s1, h2, m2, s2;
scanf("%d:%d:%d %d:%d:%d", &h1,&m1,&s1,&h2,&m2,&s2);
int tmpIn = h1*3600 + m1*60 + s1;
int tmpOut = h2*3600 + m2*60 + s2;
if(tmpIn < minn)
{
minn = tmpIn;
unlocked = t;
}
if(tmpOut > maxn)
{
maxn = tmpOut;
locked = t;
}
}
cout << unlocked << " " << locked;
return 0;
}
知识点小结
-
#include <cctype>
- 字符串常用判断函数
-
isalnum
: 字母或数字返回true -
isalpha
: 字母返回true -
isblank
: 水平制表符或空格返回true -
isdigit
: 数字(0-9)返回true -
islower
: 小写字母返回true -
ispunct
: 标点符号返回true -
isspace
: 标准空白字符,如空格、换行符、水平或垂直制表符返回true -
isupper
: 大写字母返回true -
isxdigit
: 十六进制数字,即0-9、a-f、A-F返回true -
tolower
: 大写字符,返回其小写 -
toupper
: 小写字符,返回其大写 - … …
-
#include <climits>
- 定义符号常量表示类型的限制
-
INT_MAX
-
SHRT_MAX
-
LONG_MAX
-
LLONG_MAX
-
CHAR_MAX