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 ...
随机推荐
- 【DB宝41】监控利器PMM的使用--监控MySQL、PG、MongoDB、ProxySQL等
目录 一.PMM简介 二.安装使用 三.监控MySQL数据库 MySQL慢查询分析 四.监控PG数据库 五.监控MongoDB数据库 六.监控ProxySQL中间件 一.PMM简介 之前发布过一篇Pr ...
- jquery ajax error 函数的参数及使用
使用jquery的ajax方法向服务器发送请求的时候,可选的回调函数有success.complete.beforeSend.error函数等.error函数常用来进行错误信息的处理,这里着重提一下e ...
- 统一Java环境变量配置,Java环境如何配置?
一 JDK下载和安装 Java开发工具包统一下载地址:https://www.hiai.top/archives/268.html 二 java环境变量配置 1.变量名:JAVA_HOME 变量值:你 ...
- springboot2.0全局异常处理,文件上传过大会导致,方法被执行两次,并且连接被重置
最后发现是内嵌tomcat也有文件大小限制,默认为2MB,我上传的是4MB,然后就炸了.在application.properties中添加server.tomcat.max-swallow-size ...
- mysql最权威的总结
1.数据库操作 create database person charset utf8; -- 创建数据库show DATABASES; -- 查看数据库drop database person; - ...
- python ORM之sqlalchemy
前沿对象关系映射ORM是在实际应用编程中常用到的技术,它在对象和关系之间建立了一条桥梁,前台的对象型数据和数据库中的关系型的数据通过这个桥梁来相互转化.简单来说就是开发人员在使用ORM模型编程时,不需 ...
- linux下 > /dev/null 2 > &1 的意思和如何在后台启动进程
一.几个基本符号及其含义 之前看到别人写的一个shell脚本,有一个命令是:rm -f ${src_tmp_file} > /dev/null 2>&1 现在大概明白是什么意思了 ...
- python中对类的方法中参数self的理解
我们通过下面的代码来对参数self进行理解 #coding:utf-8 2 class washer(): 3 def wash(self): 4 print("洗衣服") 5 p ...
- P1149_火柴棒等式(JAVA语言)
题目描述 给你n根火柴棍,你可以拼出多少个形如"A+B=C"的等式?等式中的A.B.C是用火柴棍拼出的整数(若该数非零,则最高位不能是0).用火柴棍拼数字0-90−9的拼法如图所示 ...
- c++ 反汇编 构造函数和析构函数
构造函数和析构函数出现的时机 局部对象 109: // 局部对象定义调用构造函数 110: 111: CNumber Number; 00C8A37D 8D 4D EC lea ecx,[Number ...