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

题目大意:福尔摩斯接到一张奇怪的字条:“我们约会吧!3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”。大侦探很快就明白了,前面两字符串中第1对相同的大写英文字母(大小写有区分)是第4个字母D,代表星期四;第2对相同的字符是E,那是第5个英文字母,代表一天里的第14个钟头(于是一天的0点到23点由数字0到9、以及大写字母A到N表示);后面两字符串第1对相同的英文字母s出现在第4个位置(从0开始计数)上,代表第4分钟。现给定两对字符串,要求解码得到约会的时间~

分析:按照题目所给的方法找到相等的字符后判断即可,如果输出的时间不足2位数要在前面添0,即用%02d输出~

#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;
}

1061. Dating (20)-PAT甲级真题相关推荐

  1. 1120. Friend Numbers (20)-PAT甲级真题

    1120. Friend Numbers (20) Two integers are called "friend numbers" if they share the same ...

  2. 1042. Shuffling Machine (20)-PAT甲级真题

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  3. 1081. Rational Sum (20)-PAT甲级真题

    Given N rational numbers in the form "numerator/denominator", you are supposed to calculat ...

  4. 1077. Kuchiguse (20)-PAT甲级真题

    The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...

  5. 1031. Hello World for U (20)-PAT甲级真题

    Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. ...

  6. 1108. Finding Average (20)-PAT甲级真题

    The basic task is simple: given N real numbers, you are supposed to calculate their average. But wha ...

  7. PAT甲级真题目录(按题型整理)(转自柳神)

    转载自:https://www.liuchuo.net/archives/2502?tdsourcetag=s_pcqq_aiomsg 最短路径 1003. Emergency (25)-PAT甲级真 ...

  8. PAT甲级真题 1018 A+B in Hogwarts--python解法

    PAT甲级真题 1018 A+B in Hogwarts 提交:2638 通过:1559 通过率:59% If you are a fan of Harry Potter, you would kno ...

  9. 【PAT甲级真题整理三】1061~1090

    目录 1061 Dating(20)字符串处理 1062 Talent and Virtue(25)排序 1063 Set Similarity(25)set的使用 1064 Complete Bin ...

最新文章

  1. 强化学习之gym初战实战案例:悬崖案例CliffWalking-v0。
  2. linux文件系统简介
  3. 深度学习数学基础(三): 激活函数、正则化函数、损失函数、评价指标
  4. 20145309 《信息安全系统设计基础》第5周学习总结
  5. 【英语学习】【Level 08】U03 My Choice L2 All-time favorite character
  6. 【Elasticsearch】Lucene 中的 Stored Fields 存储优化 自定义 存储类型 序列化 方式
  7. 【HISI系列】之SDK编码器开发
  8. hnu 暑期实训之最少钱币数
  9. 雷林鹏分享:MySQL DELETE 语句
  10. c语言计算燃烧温度,f与c温度换算(温度f和c换算计算器)
  11. HBuilderX前端html功能应用
  12. 卸载360天擎-奇安信
  13. Spring 学习笔记(day02)
  14. iOS关闭键盘的两种简单方法
  15. Oracle 考试题 原题
  16. Linux内核4.14版本——mmc core(7)——mmc core主模块(3)总线io setting相关(struct mmc_ios)
  17. 算术编码算法的程序实现
  18. 计算机主机风扇怎么庄,机箱风扇怎么装,小编教你电脑机箱风扇怎么装
  19. 调用聚合数据平台天气接口
  20. 数美科技成为《人工智能从业人员能力要求》等五项人才培养行业标准起草组全权成员单位

热门文章

  1. java 关键字null
  2. 如何使用Android系统属性(SystemProperties)
  3. 小程序成长之路(一)-- 第一个完整demo
  4. 利用java poi对excel表的读写操作
  5. python \uxxxx转中文,Python列表中的字典 \uxxxx转中文,
  6. Android初始化语言 (init.*.rc、init.conf文件格式)
  7. 聊天记录曝光,T-Mobile 证实内部工具和源代码遭 Lapsus$ 访问
  8. 谷歌修复 Chrome 站点隔离绕过漏洞
  9. 速修复!CISA警告称 Zoho 服务器0day已遭在野利用
  10. 美英澳联合发布2020-2021期间遭利用最多的 Top 30漏洞