A1061. 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
#include<cstdio>
#include<iostream>
#include<string.h>
using namespace std;
char date[][] = {" ", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
int w2num(char e){
if(e >= '' && e <= '')
return e - '';
else return e - 'A' + ;
}
int isw(char a){
return a >= 'a' && a <= 'z' || a >= 'A' && a <= 'Z';
}
int main(){
char str[][], ch1 = '\0', ch2;
int count = ;
for(int i = ; i < ; i++)
scanf("%s", str[i]);
for(int i = ; i < strlen(str[]) ; i++){
if(ch1 == '\0' && str[][i] == str[][i] && str[][i] >= 'A' && str[][i] <= 'G'){
ch1 = str[][i];
continue;
}
if(ch1 != '\0' && str[][i] == str[][i] && ((str[][i] >= '' && str[][i] <= '') || (str[][i] >= 'A' && str[][i] <= 'N'))){
ch2 = str[][i];
break;
}
}
for(count = ; str[][count] != '\0' && str[][count] != '\0'; count++)
if(str[][count] == str[][count] && isw(str[][count]))
break;
printf("%s %02d:%02d", date[ch1 - 'A' + ], w2num(ch2), count);
cin >> ch1;
return ;
}
1、第一个星期,选取的是同下标的、大写字母在A-G上的相同字母;第二个小时,是同下标、大写字母在A到N或者是数字的相同字符;第三个分钟是相同字母的下标。容易忽略的是星期的大写字母只有7个,小时的大写字母只有14个。
A1061. Dating的更多相关文章
- PAT甲级——A1061 Dating
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...
- PAT/字符串处理习题集(一)
B1006. 换个格式输出整数 (15) Description: 让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个 ...
- PAT题目AC汇总(待补全)
题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...
- 1061 Dating (20 分)
1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- hdu 2578 Dating with girls(1)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the ...
- 10 signs you’re dating the wrong person
10 signs you’re dating the wrong person10个迹象表明TA不是你的真心人 Do you have any exes who were so awful ...
- hdoj 2579 Dating with girls(2)【三重数组标记去重】
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Dating with girls(1)(二分+map+set)
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
随机推荐
- vue开发小结(下)
前言 继前几天总结了vue开发小结(上)后,发现还有很多的点没有能列举出来,于是还是打算新建一个下篇,再补充一些vue开发中需要注意的细节,确实还是都是细节的问题,我只是在这里强调下,希望对大家有帮助 ...
- IOS 上架到App Store被拒的常见问题总结
Guideline 2.3.3 - Performance - Accurate Metadata 2017年11月16日 上午12:52 发件人 Apple 2. 3 Performance: Ac ...
- mongo java 踩坑记
为什么会有这么多坑 1. Java会把 id:String = "合法ObjectId" 好心好意的 转为 _id:ObjectId 类型. 2. 为了避免第1点, 我定义了 ...
- HTML5-indexedDB使用常见错误总结
indexedDB使用过程中常常会出现以下错误: Failed to execute ‘createObjectStore’ on ‘IDBDatabase’: The database is not ...
- python基础学习笔记(八)
创建自已对象就python非常核心的概念,事实上,python被称为面向对象语言,本章会介绍如何创建对象.以及面向对象的概念:继承.封装.多态. 多态: 可对不同类的对象使用同样的操作. 封装:对外部 ...
- 第八次Scrum meeting
第八次Scrum meeting 任务及完成度: 成员 12.29 12.30 陈谋 任务1040:完成stackoverflow的数据处理后的json处理(99%) 任务1114-1:完成对网页数 ...
- Java实验报告一:Java开发环境的熟悉
实验要求: 1. 使用JDK编译.运行简单的Java程序 2.使用Eclipse 编辑.编译.运行.调试Java程序 实验内容 (一) 命令行下Java程序开发 (二)Eclipse下Java程序 ...
- 20135327郭皓--Linux内核分析第九周 期中总结
Linux内核分析第九周 期中总结 一.知识概要 1. 计算机是如何工作的 存储程序计算机工作模型:冯诺依曼体系结构 X86汇编基础 会变一个简单的C程序分析其汇编指令执行过程 2. 操作系统是如何工 ...
- bate版说明书
本游戏是一款手机游戏,学生可以在无聊时打发时间,放松心情.现在只有十关,游戏运行还算可以. 特点: 对alpha版进行了修改,可以进行暂停,重开,返回目录. 画面也进行了优化,不象之前的那么粗超. 游 ...
- PAT 甲级 1130 Infix Expression
https://pintia.cn/problem-sets/994805342720868352/problems/994805347921805312 Given a syntax tree (b ...