1061. Dating (20)
来源:互联网 发布:2017盒子看电影软件 编辑:程序博客网 时间:2024/04/28 14:38
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:3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&HyscvnmSample Output:
THU 14:04
需要注意的是:
(2)注意输出时,若为个位数,需要补0
(3)不要傻傻的用case,可以建立一个数组,存放相应输出。
#include<iostream>#include<string>#include <iomanip>using namespace std;int main(){//freopen("in.txt","r",stdin);string s1,s2,s3,s4;getline(cin,s1);getline(cin,s2);getline(cin,s3);getline(cin,s4);int i=0;int k=0;//65 int m='A';//97 int s='a';while(k!=2){if(k==0){while(s1[i]>'G'||s1[i]<'A'||s1[i]!=s2[i])i++;}if(k==1){i++;while((s1[i]>'N'||s1[i]<'A')||s1[i]!=s2[i]){if(s1[i]<='9'&&s1[i]>='0'&&s1[i]==s2[i])break;i++;}}k++;int m=s1[i]-'A'+1;if(k==1){switch (m){case 1:cout<<"MON ";break;case 2:cout<<"TUE ";break;case 3:cout<<"WED ";break;case 4:cout<<"THU ";break;case 5:cout<<"FRI ";break;case 6:cout<<"SAT ";break;case 7:cout<<"SUN ";break;};}if(k==2){if(m>=0&&m<=14){cout<<m+9;}else cout<<setw(2)<<setfill('0')<<s1[i];}}i=0;while(s3[i]!=s4[i]||s3[i]<'A'||s3[i]>'z')i++;cout<<":"<<setw(2)<<setfill('0')<<i;system("pause");return 0;}
- 1061. Dating (20)-PAT
- 【PAT】1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- PAT 1061. Dating (20)
- pat 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- pat 1061. Dating (20)
- 1061. Dating (20)
- PAT 1061. Dating (20)
- 1061. Dating (20)
- 1061. Dating (20)
- PAT 1061. Dating (20)
- 1061. Dating (20)
- [Java Concurrency in Practice]第十一章 性能与可伸缩性
- 独立思考的重要性
- leetcode: (104) Maximum Depth of Binary Tree
- IP协议
- 我知道你最爱说的就是【以后有空】
- 1061. Dating (20)
- arm9挂载nfs命令
- django数据库表结构自动迁移
- 九度OJ 题目1154:Jungle Roads
- Nginx+PHP-FPM优化技巧总结
- redis学习记录(redis的持久化操作、基于java的jedis操作)
- php yii框架 目录说明
- 2014--2015年年终总结
- TCP协议疑难杂症解析