PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
. It took him only a minute to figure out that those strange strings are actually referring to the coded time Thursday 14:04
-- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter D
, representing the 4th day in a week; the second common character is the 5th capital letter E
, representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A
to N
, respectively); and the English letter shared by the last two strings is s
at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.
Input Specification:
Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.
Output Specification:
For each test case, print the decoded time in one line, in the format DAY HH:MM
, where DAY
is a 3-character abbreviation for the days in a week -- that is, MON
for Monday, TUE
for Tuesday, WED
for Wednesday, THU
for Thursday, FRI
for Friday, SAT
for Saturday, and SUN
for Sunday. It is guaranteed that the result is unique for each case.
Sample Input:
3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm
Sample Output:
THU 14:04
题意:
题目看不懂啊,原来位置也要相同。。。范围也没弄清楚,是A~G,0~9,A~N,不分大小写。
给出四个字符串,前两个字符串确定日期和小时, 后两个字符串确定分钟;
日期:前两个字符串第一个相等的大写字母(位置相同,字母相同)A~G 分别表示星期一到星期天
小时:在找到日期的字符串后面继续查找,找到第一个相同的数字或字母(0~9,A~N)(位置也要相同),分别表示0~23
分钟:在后面两个字符串中查找,第一个相等的字母,不分大小写, 字母相等的位置就是分钟
题解:
这里用cctype中的isalpha(),isdigit()判断字符是否为字母,或者数字。也可以用不等式来判断
AC代码:
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
char a[],b[];
string week[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
int main(){
cin>>a>>b;
string wk;
int hh,mm;
int f=;
int la=strlen(a),lb=strlen(b);
for(int i=;i<min(la,lb);i++){
if(f&&((a[i]>='A' && a[i]<='N')||(a[i]>='' && a[i]<=''))&&a[i]==b[i]){
if(a[i]>='A' && a[i]<='N') {
hh=a[i]-'A'+;
break;
}
else {
hh=a[i]-'';
break;
}
}
if(!f&&a[i]>='A' && a[i]<='G' &&a[i]==b[i]){
f=;
wk=week[a[i]-'A'];
}
} memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
cin>>a>>b;
la=strlen(a);
lb=strlen(b);
for(int i=;i<min(la,lb);i++){
if(isalpha(a[i])&& a[i]==b[i]) {
mm=i;
break;
}
}
printf("%s %02d:%02d",wk.c_str(),hh,mm);
return ;
}
PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)的更多相关文章
- PAT甲级——1061 Dating (20分)
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Person ...
- PAT甲级——1061 Dating
1061 Dating Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2 ...
- 【PAT甲级】1061 Dating (20 分)
题意: 给出四组字符串,前两串中第一个位置相同且大小相等的大写字母(A~G)代表了周几,前两串中第二个位置相同且大小相等的大写字母或者数字(0~9,A~N)代表了几点,后两串中第一个位置相同且大小相等 ...
- PAT Basic 1014 福尔摩斯的约会 (20 分) Advanced 1061 Dating (20 分)
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...
- PAT甲级——1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT甲级1061 Dating
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608 题意: 给定四个字符串. 前两个字符串 ...
- PAT甲级——1005.SpellItRight(20分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
随机推荐
- EditPlus编译运行java文件
ok ---------------两张图完成
- git合并之 merge和rebase
合并有两种方法: git rebase 和git merge 优先用 rebase!!!! 区别: 1. 使用git merge git checkout dev git merge master 或 ...
- OTFS Research Notes
△f = f·v·cosθ/c,f表示载波频率,5G/B5G朝着毫米波等高频段方向发展,因此多普勒拓展的影响将更显著.此外,Masssive MIMO的现有规模已达256维度,并将朝着上千的规模发展. ...
- 学习了武沛齐讲的Day10-完
int 整形 int 将字符串转换为数字 x.bit_length() ===== 当前数字的二进制,至少用n位表示 str 字符串 x.capitalize()== ...
- 12 | 为什么我的MySQL会“抖”一下?
平时的工作中,不知道你有没有遇到过这样的场景,一条SQL语句,正常执行的时候特别快,但是有时也不知道怎么回事,它就会变得特别慢,并且这样的场景很难复现,它不只随机,而且持续时间还很短. 看上去,这就像 ...
- java上传1t文件
我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用.此控件PC全平台支持包括mac,linux系统的文件上传,文章末尾将附上控件下载与教程链接 ...
- luogu 1593
$Answer = A ^ B $ 的因子之和 将 $A$ 进行质因数分解$A = p_1 ^ {a_1} P_2 ^ {a_2} p_3 ^ {a_3} \cdots p_k ^ {a_k}$ $A ...
- [Luogu] 教主的魔法
https://www.luogu.org/problemnew/show/P2801 分块 对于每一块进行排序存储在另一个数组中 二分查询 #include<iostream> #inc ...
- 不用中间变量交换a和b的值?
a = b = a = a+b b = a-b a = a-b print(a,b) a = b = a = a^b b = b^a a = a^b print(a,b) a = b = a,b = ...
- windows下java环境变量标准配置
配置步骤 1.“此电脑”右键,选择“属性”,点击“高级系统设置”,点击“环境变量”. 2.在“系统变量”这一栏,点击“新建”,变量名:JAVA_HOME,变量值:C:\Program Files\Ja ...