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. 微信小程序去除页面滚动条

    ::-webkit-scrollbar { width: 0; height: 0; color: transparent; display: none; } 父级元素(滚动的元素) width:10 ...

  2. Centos7网络配置——设置固定ip

    有段时间没有用虚拟机了,这几天翻出了以前的虚拟机,写几个demo,但遇到了一个让人难受的问题.使用xshell远程连接虚拟机,命令还没敲几个,不到一分钟就自动断开了,只能重新再次连接.啥事都干不成,有 ...

  3. Python基础(2)——循环和分支[xiaoshun]

    一.瞎扯 世界上一切的系统都可以被'分支'表示.循环也是分支,只不过又重复之前的'分支'选择罢了.程序如人生,每一次的'分支',每一次的选择,都会有不同的结果: 有的选择止步不前,无限循环: 有的选择 ...

  4. 【Django必备01】——什么是Django框架?有什么优势?模块组成介绍。

    01.什么是Django框架? Django是一个开放源代码的Web应用框架,由Python写成.采用了MTV的框架模式.使用这种架构,程序员可以方便.快捷地创建高品质.易维护.数据库驱动的应用程序. ...

  5. android分析之mutex

    Android的锁是对Linux锁的一种包装: // ------------------------------------------------------------------------- ...

  6. Codeforces Round #557 B. Double Matrix

    题面: 传送门 题目描述: 给出两个n*m的矩阵,问:是否能通过交换两个矩阵"对应"位置的元素,使两个矩阵都为"递增"矩阵. "递增"矩阵定 ...

  7. POJ_2253 Frogger 【最短路变形】

    一.题目 Frogger 二.分析 题意关键点就是那个青蛙距离.就是所有1到2的点的路径中,每条路径都可以确定一个最大值,这个最大值就是青蛙要跳的青蛙距离,然后要求这个青蛙距离最小值. 其实就是最短路 ...

  8. C# 调用HTTP接口两种方式

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  9. springboot源码解析-管中窥豹系列之BeanDefine如何加载(十三)

    一.前言 Springboot源码解析是一件大工程,逐行逐句的去研究代码,会很枯燥,也不容易坚持下去. 我们不追求大而全,而是试着每次去研究一个小知识点,最终聚沙成塔,这就是我们的springboot ...

  10. 微信小程序--简约风博客小程序(基于云开发 - 全开源)

    微信小程序--简约风博客小程序(基于云开发 - 全开源) 项目启动纯属突发奇想,想看看博客小程序,例如wehalo博客小程序,但是感觉自建平台还要浪费自己的服务器算力,还没有访问量,省省吧. 本着白嫖 ...