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

考察内容是字符串处理。
这是很久之前的写法。

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char ans1[100],ans2[100],ans3[100],ans4[100];
    const char week[7][7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    cin.get(ans1,100);
    getchar();
    cin.get(ans2,100);
    getchar();
    cin.get(ans3,100);
    getchar();
    cin.get(ans4,100);
    getchar();
//  printf("%s",ans1);
    int len1=strlen(ans1);
    int len2=strlen(ans2);
    int len3=strlen(ans3);
    int len4=strlen(ans4);
    int i;
    for(i = 0;i<len1&&i<len2;i++)
    {
        if(ans1[i]==ans2[i]&&ans1[i]>='A'&&ans1[i]<='G')
        {
            printf("%s ",week[ans1[i]-'A']);break;
        }
    }
    for(i++;i<len1&&i<len2;i++)
    {
        if(ans1[i]==ans2[i])
        {
            if(ans1[i]>='0'&&ans1[i]<='9')
            {
                printf("%02d:",ans1[i]-'0');break;
            }
            else if(ans1[i]>='A'&&ans1[i]<='N')
            {
                printf("%02d:",ans1[i]-'A'+10); break;
            }
        }
    }
    for(int j=0;j<len3&&j<len4;j++)
    {
        if(ans3[j]==ans4[j]&&((ans3[j]>='A'&&ans3[j]<='Z')||(ans3[j]>='a'&&ans3[j]<='z')) )
        {
                printf("%02d",j);break;
        }
    }
    return 0;
 } 

参考了柳婼解法,人家的解法是这个:

#include <iostream>
#include <cctype>
using namespace std;
int main() {
        string a, b, c, d;
        cin >> a >> b >> c >> d;
        char t[2];
        int pos, i = 0, j = 0;
        while(i < a.length() && i < b.length()) {
                if (a[i] == b[i] && (a[i] >= 'A' && a[i] <= 'G')) {
                        t[0] = a[i];
                        break;
                    }
                i++;
                }
         i = i + 1;
         while (i < a.length() && i < b.length()) {
         if (a[i] == b[i] && ((a[i] >= 'A' && a[i] <= 'N') || isdigit(a[i]))) {
                 t[1] = a[i];
                 break;
         }
         i++;
 }
             while (j < c.length() && j < d.length()) {
                     if (c[j] == d[j] && isalpha(c[j])) {
                     pos = j;
                     break;
     }
         j++;
 }
 string week[7] = {"MON ", "TUE ", "WED ", "THU ", "FRI ", "SAT ", "SUN "};
 int m = isdigit(t[1]) ? t[1] - '0' : t[1] - 'A' + 10;
 cout << week[t[0]-'A'];
 printf("%02d:%02d", m, pos);
 return 0;
}

PAT甲级——1061 Dating (20分)的更多相关文章

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

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

  2. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  3. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  4. PAT甲级——1061 Dating

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

  5. 【PAT甲级】1061 Dating (20 分)

    题意: 给出四组字符串,前两串中第一个位置相同且大小相等的大写字母(A~G)代表了周几,前两串中第二个位置相同且大小相等的大写字母或者数字(0~9,A~N)代表了几点,后两串中第一个位置相同且大小相等 ...

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

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

  7. PAT甲级——1035 Password (20分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  8. 1061 Dating (20分)

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

  9. PAT甲级1061 Dating

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608 题意: 给定四个字符串. 前两个字符串 ...

随机推荐

  1. Java 统计整数二进制中1的个数

    package cookie; public class CountBinary_1 { public static void main(String[] args) { System.out.pri ...

  2. hashCode equals hashSet

    基于hash的map也是这种机制. HashSet import java.util.HashSet; import java.util.Set; import java.util.TreeSet; ...

  3. [题解] LuoguP6075 [JSOI2015]子集选取

    传送门 ps: 下面\(n\)和\(k\)好像和题目里的写反了...将就着看吧\(qwq\) 暴力打个表答案就出来了? 先写个结论,答案就是\(2^{nk}\). 为啥呢? 首先你需要知道,因为一个集 ...

  4. Python安装bs4

    - 需要将pip源设置为国内源,阿里源.豆瓣源.网易源等 - windows (1)打开文件资源管理器(文件夹地址栏中) (2)地址栏上面输入 %appdata% (3)在这里面新建一个文件夹 pip ...

  5. Bulma CSS - CSS类

    Bulma CSS框架教程 Bulma CSS – 简介 Bulma CSS – 开始 Bulma CSS – CSS类 Bulma CSS – 模块化 Bulma CSS – 响应式 Bulma是一 ...

  6. distpicker.js 根据当前位置初始化select

    学习参考的地址放在最醒目的地方: https://blog.csdn.net/idea_boy/article/details/58280076 百度官方实例:http://developer.bai ...

  7. 使用BurpSuite和Hydra爆破相关的服务(9.25 第十一天)

    使用BP和Hydra爆破相关的服务 Hydra:九头蛇,开源的功能强大的爆破工具,支持的服务有很多,使用Hydra爆破C/S架构的服务. 使用BurpSuite爆破web服务 DVWA:web应用程序 ...

  8. VMware Workstation 不可恢复错误: (vcpu-0) vcpu-0:VERIFY vmcore/vmm/main/physMem_monitor.c:1123

    在新机器上,启动虚拟机报了个错: 使用VMware® Workstation 11.1.2 build-2780323安装MacOS系统时出现以下错误: VMware Workstation 不可恢复 ...

  9. mysql 锁表的处理方式

    MySQL错误:ERROR 1205 (HY000): Lock wait timeout   处理方案:   执行mysql命令:show full processlist;   然后找出插入语句的 ...

  10. C++命名规范——谷歌规范

    1.文件命名规则 文件名全部小写,可以含下划线或连字符,按项目约定命名,且尽量保证文件名明确.比如: cmd_save_player_info_class.cc ,my_use_full_class. ...