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-9 ‘A’ - ‘N’)所以不能单纯的用isupper()来判断,分钟数所对应的时第三组和第四组字符串中第一个相等英文字符的下标。

思路:

  模拟。

Code:

 1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 int main() {
6 string str1, str2, str3, str4;
7 cin >> str1 >> str2 >> str3 >> str4;
8 string week[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
9 int i = 0, j = 0, hour;
10 string day;
11 while (i < str1.length() && i < str2.length()) {
12 if (str1[i] == str2[i] && (str1[i] >= 'A' && str1[i] <= 'G')) {
13 day = week[str1[i] - 'A'];
14 break;
15 }
16 i++;
17 }
18 i = i + 1;
19 while (i < str1.length() && i < str2.length()) {
20 if (str1[i] == str2[i]) {
21 if (str1[i] >= 'A' && str1[i] <= 'N') {
22 hour = str1[i] - 'A' + 10;
23 break;
24 } else if (isdigit(str1[i])) {
25 hour = str1[i] - '0';
26 break;
27 }
28 }
29 i++;
30 }
31 while (j < str3.length() && j < str4.length()) {
32 if (str3[j] == str4[j] && isalpha(str3[j])) break;
33 j++;
34 }
35 cout << day;
36 printf(" %02d:%02d\n", hour, j);
37 return 0;
38 }

1061 Dating的更多相关文章

  1. 1061 Dating (20 分)

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

  2. PAT 1061 Dating[简单]

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

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

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

  4. PAT甲级——1061 Dating

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

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

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

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

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

  7. 1061 Dating (20分)

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

  8. 1061. Dating (20)

    #include <stdio.h> #include <map> #include <string.h> #include <ctype.h> usi ...

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

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

随机推荐

  1. Sapper:迈向理想的 Web 应用框架

    ​扎稳阵脚,再进一步. 注意:原文发表于2017-12-31,随着框架不断演进,部分内容可能已不适用. 给迫不及待的小伙伴们的快速入门:Sapper 文档 和快速模板 starter template ...

  2. 在16G笔记本上安装GaussDB 200

    云主机太贵(最便宜的每月几千吧),长期如果需要GaussDB200有个功能测试或学习环境,那么性价比最高的方式还是在自己的笔记本电脑上尝试安装一个本地的数据库进行学习和功能验证. 01 安装环境信息 ...

  3. QQ 邀你上线小程序,官方生态能力持续赋能你的小程序

    转: QQ 邀你上线小程序,官方生态能力持续赋能你的小程序 你身边总有一些朋友,他们的表情包极其丰富,能时刻应对各种聊天场景. 表情包奇奇怪怪,可可爱爱,非常形象生动体现我们当下的心情,逐渐成为社交平 ...

  4. 微信小程序日期时间选择器(精确到秒)

    <picker mode="multiSelector" value="{{dateTime1}}" bindchange="changeDat ...

  5. LeetCode-二叉树的镜像

    二叉树的镜像 二叉树的镜像 给定一个二叉树,输出二叉树的镜像. 只需要使用一个简单的递归,分别对左右子树反转后再对当前结点进行反转. #include<iostream> #include ...

  6. dom_bom学习

    1. bom是什么? browser object model(浏览器对象模型) 在浏览器中 window指的就是bom对象 //网页重定向 // window.location.href=" ...

  7. ES系列(一):编译准备与server启动过程解析

    ES作为强大的和流行的搜索引擎服务组件,为我们提供了方便的和高性能的搜索服务.在实际应用中也是用得比较爽,但如果能够更深入一点.虽然网上有许多的文章已经完整说明,ES是如何如何做到高性能,如何做到高可 ...

  8. mysql-canal-rabbitmq 安装部署教程

    原文 1.1. 开启 MySQL 的 binlog 日志 修改 my.cnf 或 my.ini(windows), 添加配置项: # binlog 日志存放路径 log-bin=D:\env\mysq ...

  9. Hi3559AV100 NNIE开发(2)-RFCN(.wk)LoadModel及NNIE Init函数运行过程分析

    之后随笔将更多笔墨着重于NNIE开发系列,下文是关于Hi3559AV100 NNIE开发(2)-RFCN(.wk)LoadModel及NNIE Init函数运行过程分析,通过对LoadModel函数及 ...

  10. influxDB安装部署及入门

    1.下载安装包,本文使用1.7.7版本 https://portal.influxdata.com/downloads/ 2.安装 yum localinstall influxdb-1.7.7.x8 ...