PAT 甲级 1061. Dating (20)
来源:互联网 发布:网络用语吃鸡什么意思 编辑:程序博客网 时间:2024/05/22 12:52
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
#include <iostream>#include <vector>#include <algorithm>#include <string>#include <stack>#include <queue>using namespace std;#define min(a,b) (a)>(b)?(b):aint main() {string a, b, c, d;cin >> a >> b >> c >> d;int min1 = min(a.length(), b.length());int min2 = min(c.length(), d.length());string week[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };char t[2];int pos, j;for (int i = 0; i < min1; i++) {if (a[i] == b[i] && a[i] >= 'A'&&a[i] <= 'G') {t[0] = a[i];j = i;break;}}for (int i = j + 1; i < min1; i++) {if (a[i] == b[i] && ((a[i] >= 'A'&&a[i] <= 'N') || isdigit(a[i]))) {t[1] = a[i];break;}}for (int i = 0; i < min2; i++) {if (c[i] == d[i] && isalpha(c[i])) {pos = i;break;}}int m = t[1] - '0';if (!isdigit(t[1])) m = t[1] - 'A' + 10;cout << week[t[0] - 'A'];printf(" %02d:%02d\n", m, pos);cin >> a;return 0;}
- 【PAT甲级】1061. Dating (20)
- 1061. Dating (20)PAT甲级
- PAT甲级1061. Dating (20)
- PAT 甲级 1061. Dating (20)
- PAT甲级 1061. Dating (20)
- 1061. Dating (20)-PAT甲级真题
- PAT甲级练习1061. Dating (20)
- PAT(甲级)Dating (20)
- 1061. Dating (20)-PAT
- 【PAT】1061. Dating (20)
- PAT 1061. Dating (20)
- pat 1061. Dating (20)
- pat 1061. Dating (20)
- PAT 1061. Dating (20)
- PAT 1061. Dating (20)
- PAT (Advanced) 1061. Dating (20)
- PAT A 1061. Dating (20)
- PAT-A 1061. Dating (20)
- JDK学习-CountDownLatch/CyclicBarrier
- C++中有关类继承的知识
- linux下mysql安装
- 【洛谷】P1080国王游戏(高精)
- Vector&List的使用
- PAT 甲级 1061. Dating (20)
- js通过contentWindow控制iframe子页面元素点击事件,并把值传给父页面
- JDK学习-Stack/List
- spark机器学习笔记:设计机器学习系统
- JDK学习-Proxy
- 使用box-sizing布局
- JDK学习-IO/NIO
- SpringBoot整合MyBatis
- flandmark人脸检测库的用法