• 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. }

     好好学习,天天向上!

    我要考研

  • 相关阅读:
    【Mybatis】动态 SQL
    “中国法研杯”司法人工智能挑战赛:基于UTC的多标签/层次分类小样本文本应用,Macro F1提升13%+
    高级工技能等级认定理论部分 看了就过关
    c#删除数组中符合条件的元素
    容器安全是什么?
    「数据结构详解·五」链表
    如何快速的把m4a转换成mp3格式
    如何使用轻量应用服务器搭建Veno File Manager个人私有云网盘?
    Docker的运用场景 103.53.124.2
    删除远程桌面记录
  • 原文地址:https://blog.csdn.net/weixin_50679551/article/details/127109620