1061. Dating (20)
2015-11-27 13:55
351 查看
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:
Sample Output:
-----------------------华丽的分割线-------------------------
分析:根据要求找就可以了
代码:
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
-----------------------华丽的分割线-------------------------
分析:根据要求找就可以了
代码:
#include<cstdio> #include<cstdlib> #include<cstring> #include<cctype> #define Maxn 62 const char week[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; char input1[Maxn]; char input2[Maxn]; char input3[Maxn]; char input4[Maxn]; int main(void) { scanf("%s",input1); scanf("%s",input2); scanf("%s",input3); scanf("%s",input4); int length1 = strlen(input1); int length2 = strlen(input2); int length3 = strlen(input3); int length4 = strlen(input4); int i; for(i=0;i<length1&&i<length2;++i) { if((input1[i] == input2[i] )&& ('A' <= input1[i] && input1[i] <='G')) { printf("%s ",week[input1[i] - 'A']); break; } } for(i=i+1;i<length1&&i<length2;++i) { if(input1[i] == input2[i] && ( ( isdigit(input1[i]) || ('A' <= input1[i] && input1[i] <= 'N') )) ) { if(isdigit(input1[i])) { printf("%02d:",input1[i] - '0'); } else { printf("%02d:",input1[i]-'A'+10); } break; } } for(i=0;i<length3&&i<length4;++i) { if((input3[i] == input4[i] )&& isalpha(input3[i])) { printf("%02d",i); break; } } system("pause"); return 0; }
相关文章推荐
- 矩阵基础知识总结
- oracle的用户session
- C#_event_事件
- AngularJS的日期格式化有两种形式
- servlet的生命过程
- iOS隐藏导航条1px的底部横线
- 1058. A+B in Hogwarts (20)
- Context简单说明
- jdk历史版本查找
- 纯jascript解决手机端拍照、选图后图片被旋转问题
- 给实践者的算法学习指南
- 部署servlet
- SSH2整合学习笔记
- 数据结构和算法动态可视化
- ECshop网站搬家二三事
- Android Gallery
- double free or corruption
- 1054. The Dominant Color (20)
- 高性能MySQL读书笔记:找出谁持有锁
- 访问本机的WEB API 报400错误