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. flink任务性能优化

    如何提高 Flink 任务性能 一.Operator Chain 为了更高效地分布式执行,Flink 会尽可能地将 operator 的 subtask 链接(chain)在一起形成 task,每个 ...

  2. sql server C#操作。原文在收藏页面

    C#操作SQL Server数据库   1.概述 2.连接字符串的写法 3.SqlConnection对象 4.SqlCommand对象 5.SqlDataReader对象 6.DataSet对象 7 ...

  3. 一、VIP课程:互联网工程专题 04-Maven私服使用与插件开发

    第四课:Maven私服构建与插件开发.docx 一.maven 生命周期 知识点概要: 生命周期的概念与意义 maven 三大生命周期与其对应的phase(阶段) 生命周期与插件的关系 生命周期与默认 ...

  4. Linux_Program 前台后台 切换 查看 kill 实用 mark

    有时当我们在linux 上 输入  yum repolist  或 curl  www.XXX.  时程序由已 :Intel或system  原因   按下 ctrl+z .在Linux终端运行命令的 ...

  5. UVA - 11892 ENimEN(博弈)

    题意:有n堆石子,两个人拿,拿走最后的石子的人赢,poopi先拿,条件是,每个人必须从另外一个人最后拿过的石子堆中取石子,若那堆石子被拿没了,才可以自由地拿其他堆.要求每次拿的石子数不能为0.问谁赢. ...

  6. prometheus配置简介

    参考网页:https://my.oschina.net/wangyunlong/blog/3060776 global: scrape_interval:             15s evalua ...

  7. Java8大排序算法

    一.冒泡排序 基本思想:通过对待排序序列此前向后,依次比较相邻元素的值,若发现逆序则进行交换,使得较大的值从前面移动到后面,       类似于水下的气泡一样(是所有排序算法中效率最低的) publi ...

  8. C语言:大数求和

    点击获取题目 1410: [蓝桥杯]高精度加法 时间限制: 1 Sec  内存限制: 256 MB提交: 28  解决: 20[状态] [提交] [命题人:外部导入] 题目描述 输入两个整数a和b,输 ...

  9. python利用百度云接口实现车牌识别

    一个小需求---实现车牌识别. 目前有两个想法 调云在线的接口或者使用SDK做开发(配置环境和编译第三方库很麻烦,当然使用python可以避免这些问题) 自己实现车牌识别算法(复杂) ! 一开始准备使 ...

  10. HDU—4699 Editor 双向链表+子集和

    惨.今天聪哥选了2013 多校10做训练,结果一题都没做出来.这个题目是数据结构,正好是我强项 如果只是插入 删除 光标左右移动,那都小菜,用链表全解决,关键是那个Q k 要求 a1到aq的连续子序列 ...