PAT 1061. Dating (20)(按一定规则找俩个字符串中相同的字符)(待修改)
来源:互联网 发布:python中return的用法 编辑:程序博客网 时间:2024/06/08 18:06
#
1061. Dating (20)
时间限制
100 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 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
题目大意
- 1.找出s1,s2相同的字符(A-G内)。
- 2.完成第一步后继续在s1,s2中找相同的字符(0-9,A-N)。
- 3.找出s3,s4中相同的字符(大小写字母)。
待修改代码(问题在哪??)
#include<string>#include<iostream>#include<math.h>#include<cstdio>using namespace std;int main(int argc, char *argv[]){ string s1,s2,s3,s4; cin >> s1 >> s2 >> s3 >> s4; int len_min = min(s1.length(),s2.length()); bool flag = false; for (int i = 0; i < len_min; ++i) { if (!flag&&s1[i] == s2[i]&&s1[i] >= 'A' && s1[i] <= 'G') { flag = true; switch(s1[i] - 'A' + 1){ 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 << "STA "; break; case 7: cout << "SUN "; } continue; } if (flag&&s1[i] == s2[i]&&((s1[i] >= 'A' && s1[i] <= 'G')||(s1[i] >= '0' && s1[i] <= '9'))) { if (s1[i] >= 'A' && s1[i] <= 'N') { cout << (int)(s1[i]-'A'+10)<<":"; }else if (s1[i]>='0' && s1[i]<='9') { cout << 0 << s1[i] << ":"; } break; } } len_min = min(s3.length(),s4.length()); int i ; for (i = 0; i < len_min; ++i) { if (s3[i] == s4[i]&&((s3[i] >= 'A' && s3[i] <= 'G')||(s3[i] >= 'a' && s3[i] <= 'z'))) { break; } } printf("%02d\n",i); return 0;}
- 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 1028. List Sorting (25)(字符串排序)(待修改)
- PAT (Advanced Level) 1061. Dating (20) 字符匹配
- PAT-A1061 Dating (20)(模拟)
- c# 如何判断字符串中相同字符串的个数 (相同字符在字符串中出现的次数)
- PAT (Advanced) 1061. Dating (20)
- PAT A 1061. Dating (20)
- 【PAT甲级】1061. Dating (20)
- 1061. Dating (20)PAT甲级
- PAT-A 1061. Dating (20)
- BZOJ1977 (严格)次小生成树
- L1-013. 计算阶乘和-PAT团体程序设计天梯赛GPLT
- 《GPU高性能编程CUDA实战》学习笔记(五)
- JAVA-最最最最基础的一些知识,你知道吗?
- SSL在tomcat上的配置,nginx上的简单配置。及其注意事项
- PAT 1061. Dating (20)(按一定规则找俩个字符串中相同的字符)(待修改)
- 让更多的人知道如何用C#操作斑马条码打印机
- 安卓入门--四大组件--Service高级用法
- 幻方构造模版
- L1-021. 重要的话说三遍-PAT团体程序设计天梯赛GPLT
- 序列化的作用
- React 定义组件的参数对象
- 记录USB摄像头的几个问题
- Git常用命令解说