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 分)(位置也要相同,题目看不懂)的更多相关文章

  1. PAT甲级——1061 Dating (20分)

    Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...

  2. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  3. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  4. PAT甲级——1061 Dating

    1061 Dating Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2 ...

  5. 【PAT甲级】1061 Dating (20 分)

    题意: 给出四组字符串,前两串中第一个位置相同且大小相等的大写字母(A~G)代表了周几,前两串中第二个位置相同且大小相等的大写字母或者数字(0~9,A~N)代表了几点,后两串中第一个位置相同且大小相等 ...

  6. PAT Basic 1014 福尔摩斯的约会 (20 分) Advanced 1061 Dating (20 分)

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...

  7. PAT甲级——1035 Password (20分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  8. PAT甲级1061 Dating

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608 题意: 给定四个字符串. 前两个字符串 ...

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

随机推荐

  1. 多任务udp聊天器完整版

    import socket import threading def send_msg(udp_socket,dest_ip,dest_port): while True: send_data = i ...

  2. 洛谷P2577 午餐【贪心】【线性dp】

    题目:https://www.luogu.org/problemnew/show/P2577 题意:n个人每个人有一个打饭时间和吃饭时间,将他们分成两个队伍.每个人打到饭之后就马上去吃饭.问怎么安排可 ...

  3. javascript权威指南第11章 DOM扩展

    //javascript 权威指南 第三版 第11章 DOM扩展 //取得body元素 var body = document.querySelector("body"); //取 ...

  4. PHP基础语法之 三元运算符和其它运算符

    三元运算符和其它运算符 此外还有一些特殊的运算符和符号,我们再来进行讲解.可能以后我们需要用到.直线电机选型 符号 说明 $x? 真代码段:假代码段 判断是否为真假 ? 真情况 : 假情况; ``(反 ...

  5. JS的一些总结(函数声明和函数表达式的区别,函数中的this指向的问题,函数不同的调用方式,函数也是对象,数组中的函数调用)

    一.函数声明和函数表达式的区别: 函数声明放在if——else语句中,在IE8中会出现问题 函数表达式则不会 <script> if(true){ function f1(){ conso ...

  6. DOM操作2

    一.API和WebAPI API就是接口,就是通道,负责一个程序和其他软件的沟通,本质是预先定义的函数. Web API是网络应用程序接口.包含了广泛的功能,网络应用通过API接口,可以实现存储服务. ...

  7. P1213 时钟

    题目描述 考虑将如此安排在一个 3 x 3 行列中的九个时钟: 目标要找一个最小的移动顺序将所有的指针指向12点.下面原表格列出了9种不同的旋转指针的方法,每一种方法都叫一次移动.选择1到9号移动方法 ...

  8. Kalman实际应用总结

    目录 Kalman理论介绍 一. 简单理论介绍理论 二. 升华理论介绍 Kalman基本应用 一. Kalman跟踪/滤波 二. Kalman预测/融合(单传感器) 三. Kalman多传感器融合A ...

  9. PHP 连接本地mysql

    <?php echo microtime(true); ?> <?php $servername = "localhost"; $username = " ...

  10. Linux - /bin/sh^M: bad interpreter: No such file or directory

    问题 在Windows环境下用Notepad++写了个shell脚本,上传到Linux平台后运行报错如下: /bin/sh^M: bad interpreter: No such file or di ...