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. 使用scrapy_redis,实时增量更新东方头条网全站新闻

    存储使用mysql,增量更新东方头条全站新闻的标题 新闻简介 发布时间 新闻的每一页的内容 以及新闻内的所有图片.东方头条网没有反爬虫,新闻除了首页,其余板块的都是请求一个js.抓包就可以看到. 项目 ...

  2. spring+ehcache实战--性能优化之道

    在做系统集成平台项目的时候遇到了一个比較麻烦的问题.原因是使用考试系统的时候所依赖的是基础系统公布的webservice来获取基础数据,webservice的跨网络传输本身或多或少会对系统性能产生一定 ...

  3. python2.0_s12_day15_django框架的基本使用

    day15本节内容介绍 上节作业讲解(让行进入编辑模式,批量编辑) CSS之特殊内容补充 CSS内容补充之伪类 伪类实例:返回顶部终极版 CSS内容补充之无法被覆盖 jQuery插件 jQuery插件 ...

  4. url重写(urlrewrite)的一些系统变量

    学php也有3年了,一直对url重写不是很了解,本学用到的话都是百度一下,再复制作简单修改,一些变量的参数都不太了解什么意思,难得今天有时间,做个笔记吧! 1)可用的一些系统变量,在重写条件和重写规则 ...

  5. Unity3d 手机屏幕自动适配

    我提到手机自动适配的一个方法中:postion和Scale,“比例”概念适配手机.原始资源是480*800 经过实际项目考验,个人感觉: 1,UICamera是自动适配分辨率,UI上也是拉伸.放大UI ...

  6. iOS 使用AFN 进行单图和多图上传 摄像头/相册获取图片,压缩图片

    图片上传时必要将图片进行压缩,不然会上传失败 首先是同系统相册选择图片和视频.iOS系统自带有UIImagePickerController,可以选择或拍摄图片视频,但是最大的问题是只支持单选,由于项 ...

  7. LeetCode - Employees Earning More Than Their Managers

    Description: The Employee table holds all employees including their managers. Every employee has an ...

  8. linux如何设置用户权限

    linux与用户权限设置: 1.添加用户 首先用adduser命令添加一个普通用户,命令如下: #adduser tommy //添加一个名为tommy的用户 #passwd tommy //修改密码 ...

  9. WEB安全番外第一篇--其他所谓的“非主流”漏洞:URL跳转漏洞与参数污染

    一.URL跳转篇: 1.原理:先来看这段代码: <?php if(isset($_GET["url_redircetion_target"])){ $url_redirect ...

  10. 【BZOJ1717】[Usaco2006 Dec]Milk Patterns 产奶的模式 后缀数组

    [BZOJ1717][Usaco2006 Dec]Milk Patterns Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天产奶的质量 ...