博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1061 Dating (20 分)
阅读量:4124 次
发布时间:2019-05-25

本文共 2560 字,大约阅读时间需要 8 分钟。

 

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

C++:

/* @Date    : 2018-02-02 14:19:26 @Author  : 酸饺子 (changzheng300@foxmail.com) @Link    : https://github.com/SourDumplings @Version : $Id$*//*https://www.patest.cn/contests/pat-a-practise/1061 */#include 
#include
#include
#include
#include
#include
#include
using namespace std;const array
dayName{ {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}};int main(int argc, char const *argv[]){ string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int n1 = s1.length(); string day; int hour; int first_pos; for (int i = 0; i != n1; ++i) { if ((s1[i] >= 'A' && s1[i] <= 'G') && (s1[i] == s2[i])) { day = dayName[s1[i] - 'A']; first_pos = i; break; } } for (int i = first_pos + 1; i != n1; ++i) { if (s1[i] == s2[i]) { if (isdigit(s1[i])) { hour = s1[i] - '0'; break; } else if (s1[i] >= 'A' && s1[i] <= 'N') { hour = s1[i] - 'A' + 10; break; } } } int min; int n3 = s3.length(), n4 = s4.length(); for (int i = 0; i != n3 && i != n4; ++i) { if (isalpha(s3[i]) && s3[i] == s4[i]) { min = i; break; } } printf("%s %02d:%02d\n", day.c_str(), hour, min); return 0;}

 

转载地址:http://lfrpi.baihongyu.com/

你可能感兴趣的文章
XML 实体引用
查看>>
XML 属性vs元素
查看>>
Response.Redirect(...,true/false)的区别
查看>>
不应忽视的HTML优化
查看>>
span有固定宽度
查看>>
使用VS2010开发符合W3C标准的页面
查看>>
jQuery获得页面元素的绝对/相对位置
查看>>
使用clone()后,解决ui.datepicker 显示问题
查看>>
使用HTML5制作网页 [翻译]
查看>>
使png 图片在网页上透明显示
查看>>
web图片优化
查看>>
jQuery 原理初步探究
查看>>
预载入和JavaScript Image()对象
查看>>
浏览器渲染模式
查看>>
WebRebuilder 2010, 重构人生
查看>>
验证HTML规范
查看>>
如何直接调试线上页面的JavaScript和CSS
查看>>
安装vim中文帮助后出现乱码解决方法
查看>>
漫谈B端的沙箱技术
查看>>
IE,firefox内存溢出原因与解决方法
查看>>