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-23时,使用0-9+A-N表示;

使用后两个字符串的相同位置的小写字母的位置下标来表示分钟数。

//猛一看感觉还是挺简单的。

#include <iostream>
#include <map>
#include<cstdio>
using namespace std; int main() {
map<char,string> week;
string w[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
for(int i=;i<;i++){
week['A'+i]=w[i];
}
map<char,int> hour;
for(int i=;i<;i++){
if(i<=)
hour[i+'']=i;
else
hour['A'+i-]=i;
}
string s1,s2,s3,s4;
cin>>s1>>s2>>s3>>s4;
int len1=s1.size(),len2=s2.size();
int len3=s3.size(),len4=s4.size();
bool wk=false;
for(int i=;i<len1&&i<len2;i++){
if(!wk){
if(s1[i]>='A'&&s1[i]<='G'&&s1[i]==s2[i]){
cout<<week[s1[i]]<<" ";//现在星期找到了。
wk=true;
}
}else if(s1[i]==s2[i]){
if(isdigit(s1[i])||(s1[i]>='A'&&s1[i]<='N')){
printf("%02d:",hour[s1[i]]);break;//找到了之后就break,不然之后会有相等的。
} }
}
for(int i=;i<len3&&i<len4;i++){
if(s3[i]==s4[i]&&isalpha(s3[i])){
printf("%02d",i);break;
}
}
return ;
}

//注意在小时数找到之后就立马break,而不是还要循环,因为后面还有可能有相等的,应该break掉。

1.注意map的使用,总的来说还是挺简单的~

PAT 1061 Dating[简单]的更多相关文章

  1. PAT 1061. Dating

    题是别人出的,不按她的想法来也没办法,真心想k一顿 #include <cstdio> #include <cstdlib> using namespace std; cons ...

  2. PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)

    1061 Dating (20 分)   Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...

  3. PAT甲级——1061 Dating

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

  4. PAT 1061 - 1064 题解

    这四道题来自 13 年 08 月 30 的 PAT 测试. 代码量不大,思路也比较直接.不过第一题的处理逻辑不太清晰,需要好好把握.稍有不慎就掉进坑里了(很多人被这道 20'的题坑了一个多小时心慌意乱 ...

  5. 1061 Dating (20 分)

    1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh ...

  6. PAT (Advanced Level) 1061. Dating (20)

    简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...

  7. PAT甲级1061 Dating

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

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

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

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

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

随机推荐

  1. when an event of selector will be fired

    OP_READ Operation-set bit for read operations. Suppose that a selection key's interest set contains ...

  2. webBrowser 模拟登录

    webBrowser1.Document.GetElementById("txtUsername").InnerText = "sdsy";//fill nam ...

  3. python3.0与python2.0有哪些不同

    python3的语法跟python2哪里变了. 1. python3中1/2终于等于0.5 了 2. print "Hello World"变成了print("Hello ...

  4. 安装DatabaseLibrary

    Using pip pip install robotframework-databaselibrary From Source Download source from https://github ...

  5. JS 获取中英字符串字节长度

    正则匹配中文字: 这里限定中文字的范围,一般的使用是没什么问题的.如果要求十分严格的话,那么就只能使用更加严谨的代码匹配了 1:/([^\u0000-\u00FF])/g 2:/[^\x00-\xff ...

  6. ReactNative For Android 项目实战总结

    版权声明:本文由王少鸣原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/159 来源:腾云阁 https://www.qclo ...

  7. nohop以及后台运行的相关集合

    本文参考:https://blog.csdn.net/u011095110/article/details/78666833 1. 后台运行一个命令: & tar -czvf /mnt/aa. ...

  8. Mac - 如何在windows下打开 pages

    1.iCloud 苹果邮箱网页版打开(www.icloud.com) 2.在pages编辑完后,导出word格式.便能继续编辑.修改文档内容,有小部分字体.设计会在导出word格式后发生改变. 3.导 ...

  9. spring 配置中相关属性的含义:

    1:parent元素属性 一个bean定义可能会包含大量的配置信息,包括容器相关的信息(比如初始化方法,静态工厂方法等等)以及构造函数参数和属性的值.一个child bean定义是一个能够从paren ...

  10. 310实验室 Linux 软件安装常见问题

    电脑装好Linux系统后,系统默认安装软件不齐,需要自己根据自己的需要安装一些列工具软件,在linux系统中,用的最多的就是Synaptic Package Manager,什么是Synaptic?新 ...