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 ...
随机推荐
- docker仓库之harbor高可用 (三)
基于上一篇部署完成了企业级仓库harbor的部署,今天我们来聊聊什么是harbor的高可用 Harbor 支持基于策略的 Docker 镜像复制功能,这类似于 MySQL 的主从同步,其可以实现不同的 ...
- FakeTaobaoDeepLink - 复制淘宝deeplink来拦截淘宝广告的自动拉起
Fake Taobao Deeplink 复制 ** com.taobao.tao.welcome.Welcome ** 的intent-filter来拦截误触广告后自动拉起淘宝app 完整工程 Gi ...
- Salesforce LWC学习(三十一) Quick Action适配
本篇参考:https://www.lightningdesignsystem.com/components/modals/ 随着salesforce lwc的优化,越来越多的项目从aura转到了lwc ...
- 40. 组合总和 II + 递归 + 回溯 + 记录路径
40. 组合总和 II LeetCode_40 题目描述 题解分析 此题和 39. 组合总和 + 递归 + 回溯 + 存储路径很像,只不过题目修改了一下. 题解的关键是首先将候选数组进行排序,然后记录 ...
- 基于es实现一个简单的搜索引擎
一.什么是es Elasticsearch是一个基于ApacheLucene(TM)的开源搜索引擎.无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进.性能最好的.功能最全的搜索引擎库.但 ...
- RepVGG
RepVGG: Making VGG-style ConvNets Great Again 作者:elfin 资料来源:RepVGG论文解析 目录 1.摘要 2.背景介绍 3.相关工作 3.1 单 ...
- Python | random 模块:Python 中如何生成随机数和随机抽样?
random 是平时开发过程中常用的一个模块,该模块实现了各种分布的伪随机数生成器,以及和随机数相关的各种实用函数.基本函数 random() 在区间 [0.0, 1.0) 内均匀生成随机浮点数,是模 ...
- Java中的三大特性 - 超详细篇
前言 大家好啊,我是汤圆,今天给大家带来的是<Java中的三大特性 - 超详细篇>,希望对大家有帮助,谢谢 这一节的内容可能有点多,大家可以选择性的来看 简介 Java的三大特性:封装.继 ...
- vmstat-观察进程上线文切换
vmstat 是一款指定采样周期和次数的功能性监测工具,我们可以看到,它不仅可以统计内存的使用情况,还可以观测到 CPU 的使用率.swap 的使用情况.但 vmstat 一般很少用来查看内存的使用情 ...
- 学习笔记-vue hash模式打包
1.打包设置config->index.js 2.图片资源路径出现问题 设置下utils.js文件