1061. Dating (20)
来源:互联网 发布:python 调用批处理 编辑:程序博客网 时间:2024/05/17 09:08
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<cstring> #include<cstdio> #include<queue> #include<stack> #include<algorithm> #include<vector> #include<cmath>using namespace std;int main(){char s1[100],s2[100];char s3[100],s4[100];char day[10][10]={"MON","TUE","WED","THU","FRI","SAT","SUN"};gets(s1);gets(s2);gets(s3);gets(s4);int d=0,i;for(i=0;i<strlen(s1)&&i<strlen(s2);i++){if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G'){d=i;break;}}i++;int m=0;for(;i<strlen(s1)&&i<strlen(s2);i++){if(s1[i]==s2[i]&&((s1[i]>='A'&&s1[i]<='N')||(s1[i]>='0'&&s1[i]<='9'))){m=i;break;}}int mm=0;if(!(s1[m]>='0'&&s1[m]<='9')) mm=s1[m]-'A'+10;else mm=s1[m]-'0';printf("%s %02d:",day[s1[d]-'A'],mm);for(int i=0;i<strlen(s3)&&i<strlen(s4);i++){if(s3[i]==s4[i]&&((s3[i]>='a'&&s3[i]<='z')||(s3[i]>='A'&&s3[i]<='Z'))){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)
- 1148: [CTSC2007]挂缀pendant
- yii2怎么使用控制器
- 哈夫曼代码调试
- 对c语言回调函数的理解
- java笔记(六)之面向对象
- 1061. Dating (20)
- POJ 2104 & HDU 2665 & POJ 2761 K-th Number (主席树入门题 区间第K大)
- git 错误:error: RPC failed; HTTP 411 curl 22 The requested URL returned error: 411 Length Required
- onclick,onchange,onblue等触发性事件的区别
- Android之SurfaceView使用总结
- 快慢指针的概念及其应用
- 学习打印
- HBase源码分析之WALEdit
- Cpp_顺序表