1061. Dating (20)
来源:互联网 发布:中小型网络拓扑及搭建 编辑:程序博客网 时间:2024/06/01 07:27
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
提交代码
题目意思:
给定四个字符串,前面两个字符串包含day和hour两个信息,后面两个字符串包含minute信息。
前两个字符串的第一对相同位置的A-G大写字母表示day、A-G表示星期一到星期天。day位置后的第一对0-9或A-N的字符表示hour,从0到23。后两个字符串的第一对相同位置的英文字母表示minute。
#include <iostream>#include <cstdio>using namespace std;int main(){ char s[4][70]; int hour, minate; for(int i = 0; i < 4; i++) cin >> s[i]; int flag1 = 0,flag2 = 0; for(int i = 0; s[0][i]!='\0'&&s[1][i]!='\0';i++) { if(s[0][i] == s[1][i]&&flag1==0&&s[0][i]>='A'&&s[0][i]<='G') { flag1 = 1; flag2 = 1; if(s[0][i] == 'A') cout << "MON "; if(s[0][i] == 'B') cout << "TUE "; if(s[0][i] == 'C') cout << "WED "; if(s[0][i] == 'D') cout << "THU "; if(s[0][i] == 'E') cout << "FRI "; if(s[0][i] == 'F') cout << "SAT "; if(s[0][i] == 'G') cout << "SUN "; continue; } if(s[0][i] == s[1][i]&&flag2==1) { if(s[0][i]>='0'&&s[0][i]<='9') { printf("%02d:",s[0][i]-'0'); break; } if(s[0][i]>='A'&&s[0][i]<='N') { printf("%02d:",s[0][i]-55); break; } } } for(int i = 0; s[2][i]!='\0'&&s[3][i]!='\0';i++) { if(s[2][i] == s[3][i]&&((s[2][i]>=65&&s[2][i]<=90)||(s[2][i]>=97&&s[2][i]<=122))) { printf("%02d", i); break; } } 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)
- (M)BFS:310. Minimum Height Trees
- 字符串hash——Codeforces533F Encoding
- 开博客,记录
- vector的用法
- autofs服务之光盘自动挂载
- 1061. Dating (20)
- MySQl + java-web 数据分页案例
- Relection2017.10.18
- 表格属性介绍
- 斗地主核心代码
- 设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。
- HDU 3339 In Action
- 51nod 最小方差 1098
- 卷积神经网络概念与原理