PAT A1061. Dating (20)
2017-02-07 11:28
295 查看
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:
Sample Output:
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 <algorithm> #include <cmath> #include <cstring> #define Max 100 using namespace std; int getl(int a,int b) { if(a>b) return b; else return a; } int main() { char a[Max],b[Max],c[Max],d[Max]; char D[8][8]={"MON","TUE","WED","THU","FRI","SAT","SUN"}; char S[25][8]={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"}; scanf("%s",a); scanf("%s",b); scanf("%s",c); scanf("%s",d); int f=0,l1,l2; l1=getl(strlen(a),strlen(b)); l2=getl(strlen(c),strlen(d)); for(int i=0;i<l1;i++) { if(f==0) { if(a[i]>='A'&&a[i]<='G') { if(b[i]==a[i]){ printf("%s ",D[a[i]-'A']); f=1; } } } else { if(a[i]>='0'&&a[i]<='9') { if(b[i]==a[i]) { printf("%s:",S[a[i]-'0']); break; } } else if(a[i]>='A'&&a[i]<='N') { if(b[i]==a[i]) { printf("%s:",S[a[i]-'A'+10]); break; } } } } for(int i=0;i<l2;i++) { if((c[i]>='a'&&c[i]<='z')||(c[i]>='A'&&c[i]<='Z')){ if(c[i]==d[i]) { printf("%02d\n",i); break; } } } system("pause"); return 0; }
相关文章推荐
- 软件需求变更管理七步法
- eclipse使用github进行版本控制
- Oracle 12C DG 搭建(RAC-RAC/RAC-单机)
- Centos6.4安装图形界面,用来安装某些应用(比如Oracle)
- html 盒子模型基础(高度塌陷问题,BFC详解)(六)
- 给定一个日期,用mysql得到该日期所对应的星期一所对应的日期和星期天所对应的日期。
- 赛马比赛--25匹马5个跑道,怎样选出最快的5匹来
- 基于Nginx1.9+LuaJIT+Kafka的点播监控系统实战
- QML翻转效果Demo
- NGINX转发出现502 BAD GATEWAY的错误
- select2 及tree用法,直接代码
- 网络字节序与主机字节序
- SVM学习笔记
- CentOS 7下安装PostgreSQL 9.6的教程分享
- Android热修复之AndFix.android studio
- ubuntu右键添加打开终端的快捷菜单
- MySQL一次更新多条不同的记录
- C#的一些小知识备记(持续更新)
- Oracle 异机恢复
- mysql 5.7 disable GTID replication