PAT 1061. Dating (20)

 1 #include <iostream>
 2 #include <string>
 3
 4 using namespace std;
 5
 6 int main()
 7 {
 8     string s1, s2, s3, s4;
 9     cin >> s1 >> s2 >> s3 >> s4;
10     string day[7]{"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
11
12     int i = 0, cnt=0;
13     while (i < s1.size() && i < s2.size())
14     {
15         if (s1[i] == s2[i] && (s1[i] >= ‘A‘&&s1[i] <= ‘G‘)&&cnt == 0)
16         {
17             cout << day[s1[i] - ‘A‘] << " ";
18             cnt++;
19         }
20         else if (s1[i] == s2[i] && cnt == 1)
21         {
22             if (s1[i] >= ‘0‘&&s1[i] <= ‘9‘)
23             {
24                 cout << 0 << s1[i];
25                 cnt++;
26             }
27             else if (s1[i] >= ‘A‘&&s1[i] <= ‘N‘)
28             {
29                 cout << s1[i] - ‘A‘ + 10;
30                 cnt++;
31             }
32         }
33         if (cnt == 2)
34             break;
35         i++;
36     }
37     i = 0;
38     while (i < s3.size() && i < s4.size())
39     {
40         if (s3[i] == s4[i]&&((s3[i]>=‘a‘&&s3[i]<=‘z‘)||(s3[i]>=‘A‘&&s3[i]<=‘Z‘)))
41         {
42             if (i < 9)
43                 cout << ":0" << i;
44             else
45                 cout << ":"<< i;
46             break;
47         }
48         i++;
49     }
50
51 }

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&Hyscvnm

Sample Output:

THU 14:04
时间: 2024-10-13 19:22:23

PAT 1061. Dating (20)的相关文章

PAT (Advanced Level) 1061. Dating (20)

简单模拟. #include<stdio.h> #include<string.h> char s1[70],s2[70],s3[70],s4[70]; char f[7][5]={"MON ", "TUE ","WED ","THU ","FRI ","SAT ","SUN "}; int a,b,c,flag; int main() { s

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:0

1061. Dating (20)

1 #include <stdio.h> 2 #include <map> 3 #include <string.h> 4 #include <ctype.h> 5 using namespace std; 6 int main() 7 { 8 map<char,int> ToHour; 9 int i; 10 for(i=0;i<=9;i++) 11 ToHour['0'+i]=i; 12 for(i='A';i<='N';i++)

PAT 1061. Dating

题是别人出的,不按她的想法来也没办法,真心想k一顿 #include <cstdio> #include <cstdlib> using namespace std; const char* days[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}; inline bool is_ca

pat1061. Dating (20)

1061. Dating (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minut

PAT 1061. 判断题

PAT 1061. 判断题 判断题的评判很简单,本题就要求你写个简单的程序帮助老师判题并统计学生们判断题的得分. 输入格式: 输入在第一行给出两个不超过100的正整数N和M,分别是学生人数和判断题数量.第二行给出M个不超过5的正整数,是每道题的满分值.第三行给出每道题对应的正确答案,0代表"非",1代表"是".随后N行,每行给出一个学生的解答.数字间均以空格分隔. 输出格式: 按照输入的顺序输出每个学生的得分,每个分数占一行. 输入样例: 3 6 2 1 3 3 4

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:0

PAT 1035. Password (20)

1035. Password (20) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

PAT 1064. 朋友数(20)

如果两个整数各位数字的和是一样的,则被称为是"朋友数",而那个公共的和就是它们的"朋友证号".例如123和51就是朋友数,因为1+2+3 = 5+1 = 6,而6就是它们的朋友证号.给定一些整数,要求你统计一下它们中有多少个不同的朋友证号.注意:我们默认一个整数自己是自己的朋友. 输入格式: 输入第一行给出正整数N.随后一行给出N个正整数,数字间以空格分隔.题目保证所有数字小于104. 输出格式: 首先第一行输出给定数字中不同的朋友证号的个数:随后一行按递增顺序输出