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. VC++ 操作Windows快捷方式

    声明:本文是参考网友博文,然后自己实践整理所得,转载请注明出处! Windows的快捷方式实际上是一个带有扩展名LNK的数据文件,其中包含有用于访问Windows某一对象(即在资源管理器中所能浏览的所 ...

  2. OpenCV学习:OpenCV文件一览

    了解一些OpenCV代码整体的模块结构后,再重点学习自己感兴趣的部分,会有一种一览众山小的感觉~ Come on! C:\OpenCV\opencv\build\include文件夹下包含两个文件夹: ...

  3. POJ 1661 Help Jimmy(递推DP)

    思路: 1. 每个板子有左右两端, dp[i][0], dp[i][1] 分别记录左右端到地面的时间 2. 从下到上递推计算, 上一层的板子必然会落到下面的某一层板子上, 或者地面上 总结: 1. 计 ...

  4. iOS应用国际化教程(2014版)

    本文转载至 http://www.cocoachina.com/industry/20140526/8554.html 这篇教程将通过一款名为iLikeIt的应用带你了解最基础的国际化概念,并为你的应 ...

  5. (一)微信小程序之模拟调用后台接口踩过的坑

    如下图标记的三个点 在调试过程中出现问题,特此记录. 1. 之前在浏览器测试接口习惯省略 http:// ,是因为浏览器默认有一个检测,在你输入的网址前面加http://,如果有就不加. 然而在微信小 ...

  6. js获取一个字符串中指定字符第n次出现的位置

    function nthIndexOf(str,c,n){ var x=str.indexOf(c); for(var i=0;i<num;i++){ x=str.indexOf(c,x+1); ...

  7. 【HTML】改变鼠标样式图片css

    你需要一张图   .ico 的 格式 如果一开始你要解决的是怎么去用png 格式图片转成 ICO格式 先做一张32*32的PNG格式图片 然后 打开http://www.easyicon.net/co ...

  8. HTTP2.0简明笔记

    版权声明:本文由史燕飞原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/82 来源:腾云阁https://www.qcloud ...

  9. IOS中使用轻量级数据库

    IOS中使用轻量级数据库 目录 概述 IOS中的轻量级数据库 sqlite的方法 数据库的实用操作 第三方类库 FMDatabase 概述 IOS中的轻量级数据库 sqlite的方法 sqlite3 ...

  10. 【BZOJ5102】[POI2018]Prawnicy 堆

    [BZOJ5102][POI2018]Prawnicy Description 定义一个区间(l,r)的长度为r-l,空区间的长度为0. 给定数轴上n个区间,请选择其中恰好k个区间,使得交集的长度最大 ...