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, MONfor 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 ...
随机推荐
- celery 笔记
参考:https://blog.csdn.net/tichimi3375/article/details/82415412 中文翻译:https://www.celerycn.io/ htt ...
- win10 水晶报表安装包
windows 10 64 VS2013安装 CR For VS 13_0_18 安装过程没有报错 安装成功http://downloads.businessobjects.com/akdlm/cr4 ...
- 微信小程序导入Vant报错
作者:如也_d1c0链接:https://www.jianshu.com/p/0d2332984f8c来源:简书简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处. 先放出来Vant ...
- php利用webuploader实现超大文件分片上传、断点续传
PHP用超级全局变量数组$_FILES来记录文件上传相关信息的. 1.file_uploads=on/off 是否允许通过http方式上传文件 2.max_execution_time=30 允许脚本 ...
- DEA使用git提交代码时,点了commit之后卡死在performing code analysis部分,或者performing code analysis结束后没有进入下一步操作。
把"Perform code analysis" 和 "Check TODO" 复选框前面的勾去掉就好了. 这个可能是因为所分析的目标文件太大了,造成一直分析不 ...
- CSPS模拟88-91
感觉自己好菜啊,考得一次不如一次了...压力好大,++滚粗感. 模拟88. T1,sbt,发现离散化后数据范围变为6000,直接跑暴力即可.%%%机房众神斜率优化. T2,大模拟,考场上只会乱搞骗分. ...
- P5022 旅行
原题链接 https://www.luogu.org/problem/P5022 本着快csp了,做点往年的NOIp的题试试水来着,没想到水这么深 难度还挺大的,耗了我一天的时间(可能是我太菜了) ...
- mac 启动mysql
sudo /usr/local/mysql/support-files/mysql.server stop sudo /usr/local/mysql/support-files/mysql.serv ...
- GFS中元数据的管理
GFS 元数据(metadata)中包含三部分: GFS元数据的管理方式: 1.文件的命名空间和块的命名空间: 采用持久化的方式. 对于文件和块的命名空间以及从文件到块的映射:通过向操作日志登记修改而 ...
- python3编程基础之一:标识符
每种编程语言都是需要处理数据的,需要变量.函数.类等,而这些都是通过名称访问的.因此,能够作为变量.函数.类等名称的字符串就是标识符.数据,是计算机进行运算的实体.标识符,用来标记的符号,它会指向一个 ...