1061 Dating(20 分)

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:

  1. 3485djDkxh4hhGE
  2. 2984akDfkkkkggEdsb
  3. s&hgsfdk
  4. d&Hyscvnm

Sample Output:

  1. THU 14:04

题目大意:给出一几个字符串,根据前两个字符串的相同位置的相同大写字母确定周几,和小时数,其中A-G分别表示周一-周日;0-23时,使用0-9+A-N表示;

使用后两个字符串的相同位置的小写字母的位置下标来表示分钟数。

//猛一看感觉还是挺简单的。

  1. #include <iostream>
  2. #include <map>
  3. #include<cstdio>
  4. using namespace std;
  5.  
  6. int main() {
  7. map<char,string> week;
  8. string w[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
  9. for(int i=;i<;i++){
  10. week['A'+i]=w[i];
  11. }
  12. map<char,int> hour;
  13. for(int i=;i<;i++){
  14. if(i<=)
  15. hour[i+'']=i;
  16. else
  17. hour['A'+i-]=i;
  18. }
  19. string s1,s2,s3,s4;
  20. cin>>s1>>s2>>s3>>s4;
  21. int len1=s1.size(),len2=s2.size();
  22. int len3=s3.size(),len4=s4.size();
  23. bool wk=false;
  24. for(int i=;i<len1&&i<len2;i++){
  25. if(!wk){
  26. if(s1[i]>='A'&&s1[i]<='G'&&s1[i]==s2[i]){
  27. cout<<week[s1[i]]<<" ";//现在星期找到了。
  28. wk=true;
  29. }
  30. }else if(s1[i]==s2[i]){
  31. if(isdigit(s1[i])||(s1[i]>='A'&&s1[i]<='N')){
  32. printf("%02d:",hour[s1[i]]);break;//找到了之后就break,不然之后会有相等的。
  33. }
  34.  
  35. }
  36. }
  37. for(int i=;i<len3&&i<len4;i++){
  38. if(s3[i]==s4[i]&&isalpha(s3[i])){
  39. printf("%02d",i);break;
  40. }
  41. }
  42. return ;
  43. }

//注意在小时数找到之后就立马break,而不是还要循环,因为后面还有可能有相等的,应该break掉。

1.注意map的使用,总的来说还是挺简单的~

PAT 1061 Dating[简单]的更多相关文章

  1. PAT 1061. Dating

    题是别人出的,不按她的想法来也没办法,真心想k一顿 #include <cstdio> #include <cstdlib> using namespace std; cons ...

  2. PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)

    1061 Dating (20 分)   Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...

  3. PAT甲级——1061 Dating

    1061 Dating Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2 ...

  4. PAT 1061 - 1064 题解

    这四道题来自 13 年 08 月 30 的 PAT 测试. 代码量不大,思路也比较直接.不过第一题的处理逻辑不太清晰,需要好好把握.稍有不慎就掉进坑里了(很多人被这道 20'的题坑了一个多小时心慌意乱 ...

  5. 1061 Dating (20 分)

    1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh ...

  6. PAT (Advanced Level) 1061. Dating (20)

    简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...

  7. PAT甲级1061 Dating

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608 题意: 给定四个字符串. 前两个字符串 ...

  8. PAT Basic 1014 福尔摩斯的约会 (20 分) Advanced 1061 Dating (20 分)

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...

  9. PAT甲级——1061 Dating (20分)

    Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...

随机推荐

  1. ios开发之--ZHPickView输出格式不出现 +0000

    这样写就不会输出 +0000了 NSDate *select = [_datePicker date]; NSDateFormatter *dateFormatter = [[NSDateFormat ...

  2. python2.0_day18_django_form

    Django formDjango admin 为什么要讲form,Django里的form能做什么. 前面day16节 简单学习了Django admin,我们知道当我们的models在admin. ...

  3. HttpServletResponse status对应的状态信息

    1xx - 信息提示   这些状态代码表示临时的响应.客户端在收到常规响应之前,应准备接收一个或多个 1xx 响应.    ·0 - 本地响应成功.   · 100 - Continue 初始的请求已 ...

  4. MongoDB(一)-- 简介、安装、CRUD

    一.Mongodb简介 MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统. 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在为WEB应用提供可 ...

  5. [SQL]躺着也中枪的datetime类型

    写在前面 本来这个东西,我是不想在这里总结的,今天有初学者的朋友问我了,那就不得不说说了,你肯定也踩过这样的坑,没遇到,说明你运气好,编码习惯好.那还是言归正传吧.避免你中枪,还是扫一眼这篇文章吧. ...

  6. Django学习笔记 开发环境搭建

    为什么使用django?1.支持快速开发:用python开发:数据库ORM系统,并不需要我们手动地构造SQL语句,而是用python的对象访问数据库,能够提升开发效率.2.大量内置应用:后台管理系统a ...

  7. java基础---->多线程之interrupt(九)

    这里我们通过实例来学习一下java多线程中关于interrupt方法的一些知识.执者失之.我想当一个诗人的时候,我就失去了诗,我想当一个人的时候,我就失去了我自己.在你什么也不想要的时候,一切如期而来 ...

  8. Linux命令行常用光标移动快捷键

    Linux 命令行快捷键 涉及在Linux命令行下进行快速移动光标.命令编辑.编辑后执行历史命令.Bang(!)命令.控制命令等.让basher更有效率. 常用 ctrl+左右键:在单词之间跳转 ct ...

  9. ubuntu 14 root 账户 启用与ssh登录

    ubuntu 14.04 root用户登录 开启root帐号的方法: 为了启用root 帐号(也就是设置一个口令)使用: sudo passwd root 当你使用完毕后屏蔽root帐号使用: sud ...

  10. object.prototype.call

    object.prototype.call /* * object.prototype.call * @ 当一个object没有某个方法,但是其他的有,我们可以借助call或apply用其它对象的方法 ...