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. 【转】理清基本的git(github)流程

    概述 当我初次接触git时,我需要快速学习基本的git工作流,以便快速接收一个开源Web项目维护.但是,我很难理解工作流程,因为我不太了解git使用关键点. fork,clone,pull.branc ...

  2. POJ 1180 Batch Scheduling

    BTW: 刚在图书馆借了本算法艺术与信息学竞赛. 我多次有买这本书的冲动, 但每次在试看之后就放弃了, 倒不是因为书太难, 而是写的实在是太差. 大家对这本书的评价很高, 我觉得多是因为书的内容, 而 ...

  3. Linux printf 命令

    printf 命令用来格式化输出,用法如下: [keysystem@localhost ~]$ printf "%s\n" 1 2 3 4 1 2 3 4 [keysystem@l ...

  4. json 数据分析

    /* 健一健康头条 */ try { String url = "http://www.j1health.com/j1api.php/index/getJ1healthHotLists&qu ...

  5. web 前端规范实例

    <!DOCTYPE html> <html> <head> <title>tmall</title> <!-- 为了被搜索引擎作为流量 ...

  6. Oracle12cWindows安装、介绍及简单使用(图文)

    1.下载 地址为:http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/index.html 含企业版和 ...

  7. 实现类似printf这样的函数

    来源:http://www.vimer.cn/2009/12/cc%E5%AE%9E%E7%8E%B0%E5%A4%9A%E5%8F%82%E6%95%B0%E5%87%BD%E6%95%B0%E7% ...

  8. java高级---->Thread之CountDownLatch的使用

    CountDownLatch是JDK 5+里面闭锁的一个实现,允许一个或者多个线程等待某个事件的发生.今天我们通过一些实例来学习一下它的用法. CountDownLatch的简单使用 CountDow ...

  9. Ts中的接口interface(属性也能继承...)

    接口ITest.ts interface ITest { name:string; age:number; run(); to(x:number,y:number):number; } 必须继承接口的 ...

  10. NAS设备是什么

    1.NAS含义: NAS(Network Attached Storage)网络存储基于标准网络协议实现数据传输,为网络中的Windows / Linux / Mac OS 等各种不同操作系统的计算机 ...