• PAT 1061 Dating


    1061 Dating

    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:

    1. 3485djDkxh4hhGE
    2. 2984akDfkkkkggEdsb
    3. s&hgsfdk
    4. d&Hyscvnm

    Sample Output:

    THU 14:04

    总结:这道题目在乙级已经写过了,套路啥的都清楚,就没有难度了

    1. #include
    2. #include
    3. #include
    4. using namespace std;
    5. int main(){
    6. vector s(4);
    7. char day[7][5]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    8. for(int i=0;i<4;i++)
    9. cin >> s[i];
    10. bool sign=false;
    11. for(int i=0;i0].size() && i1].size();i++){
    12. if(s[0][i]==s[1][i] && sign==false && s[0][i]>='A' && s[0][i]<='G'){
    13. printf("%s ",day[s[0][i]-'A']);
    14. sign=true;
    15. continue;
    16. }
    17. if(s[0][i]==s[1][i] && sign==true){
    18. if(s[0][i]>='0' && s[0][i]<='9'){
    19. printf("%02d:",s[0][i]-'0');
    20. break;
    21. }
    22. else if(s[0][i]>='A' && s[0][i]<='N'){
    23. printf("%d:",s[0][i]-'A'+10);
    24. break;
    25. }
    26. }
    27. }
    28. for(int i=0;i2].size() && i3].size();i++){
    29. if(s[2][i]==s[3][i] && isalpha(s[2][i])){
    30. printf("%02d\n",i);
    31. break;
    32. }
    33. }
    34. return 0;
    35. }

     好好学习,天天向上!

    我要考研

  • 相关阅读:
    软考初级网络管理员__网络单选题
    论文《Neural News Recommendation with Attentive Multi-View Learning》阅读
    关于 Eclipse 的一场 “三角关系”
    基于MATLAB的风力光伏发电模型模拟以及遗传算法求解混合发电系统最优配置
    【打卡】牛客网:BM36 判断是不是平衡二叉树
    玻尔兹曼分布详细推导、softmax 及 Energy Based Model
    【前端】CSS(2) —— CSS的基本属性
    10kb的照片尺寸怎么弄?几个步骤轻松搞定!
    【DSP程序升级】程序升级/OTA/BootLoader开发
    【无标题】
  • 原文地址:https://blog.csdn.net/weixin_50679551/article/details/127109620