1061 Dating
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的更多相关文章
- 1061 Dating (20 分)
1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh ...
- PAT 1061 Dating[简单]
1061 Dating(20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4 ...
- PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)
1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...
- PAT甲级——1061 Dating
1061 Dating Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2 ...
- PAT Basic 1014 福尔摩斯的约会 (20 分) Advanced 1061 Dating (20 分)
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...
- PAT甲级——1061 Dating (20分)
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...
- 1061 Dating (20分)
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...
- 1061. Dating (20)
#include <stdio.h> #include <map> #include <string.h> #include <ctype.h> usi ...
- PAT (Advanced Level) 1061. Dating (20)
简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...
随机推荐
- 后端程序员之路 57、go json
go自带json处理库,位于encoding/json,里面的test很具参考意义,特别是example_test.go json - The Go Programming Languagehttps ...
- ng-class动态类几种用法
方法1.逻辑在后面的中括号里面 ng-class="{true : 'checker disabled',false : 'checker' }[selectAllButton]" ...
- PAT-1066(Root of AVL Tree)Java语言实现
Root of AVL Tree PAT-1066 这是关于AVL即二叉平衡查找树的基本操作,包括旋转和插入 这里的数据结构主要在原来的基础上加上节点的高度信息. import java.util.* ...
- ant-design-vue中table自定义列
1. 使用背景 在项目中使用ant-vue的a-table控件过程中,需要显示序号列或者在列中显示图片,超链,按钮等UI信息.经过查询文档customCell和customRender可以实现以上需求 ...
- mysql内一些可以延时注入的查询语句
一.sleep() 配合其他函数进行使用将十分方便,如下所示: 拆分讲解: select substr(database(),1,1) ; 截取当前数据库的第一位,转换为ascii码值: se ...
- crf++分词
1.linux下安装crf工具包 先下载CRF++-0.58.tar.xz,在Linux环境下安装CRF工具包 https://github.com/taku910/crfpp 解压到某一个目录下面 ...
- MySQL基础知识:MySQL Connection和Session
在connection的生命里,会一直有一个user thread(以及user thread对应的THD)陪伴它. Connection和Session概念 来自Stackoverflow的一个回答 ...
- python-链队列的实现
7 class Node(object): 8 def __init__(self,data): 9 self.data = data 10 self.next = None 11 12 class ...
- .Net5 下Dictionary 为什么可以在foreach中Remove
在一个讨论群里,看见有人说Dictionary可以在foreach中直接调用Remove了,带着疑问,写了简单代码进行尝试 class Program { static void Main(strin ...
- Apache JMeter 5.4.1 Build Development
1. 说明 经过漫长的等待终于将开发环境搭建成功了!网络慢真的是伤不起!grade,确实要比maven简洁.....嗯!真香! 2. 工具准备 JDK1.8+ 这... ...