• 牛客网PAT练兵场-福尔摩斯的约会


    题目地址:https://www.nowcoder.com/pat/6/problem/4040

    题意:模拟题,循环找相同的字母,但是注意题目的坑

     1 /**
     2 *
     3 *作者:Ycute
     4 *时间:2019-11-14-20.12.04
     5 *题目题意简单描述:遍历
     6 */
     7 
     8 
     9 #include<iostream>
    10 #include<cmath>
    11 #include<cstring>
    12 #include<algorithm>
    13 #include<vector>
    14 using namespace std;
    15 
    16 
    17 int main(){
    18     char a[65];
    19     char b[65];
    20     char c[65];
    21     char d[65];
    22     scanf("%s",a);
    23     getchar();
    24     scanf("%s",b);
    25     getchar();
    26     scanf("%s",c);
    27     getchar();
    28     scanf("%s",d);
    29     getchar();
    30     int flag=0;
    31     char day,hh;
    32     int min=0;
    33     for(int i=0;i<strlen(a);i++){
    34         if(a[i]==b[i]){
    35             if(flag==0){
    36                 if(a[i]>='A'){
    37                     day=a[i];
    38                     flag=1;
    39                 }
    40             }else if(flag==1){
    41                 if((a[i]>='0'&&a[i]<='9')||(a[i]>='A'&&a[i]<='N')){
    42                     hh=a[i];
    43                     flag=2;
    44                     break;
    45                 }
    46             }
    47         }
    48     }
    49     flag=0;
    50     for(int i=0;i<strlen(c);i++){
    51         if(c[i]==d[i]){
    52            if((c[i]>='a'&&c[i]<='z')||(c[i]>='A'&&c[i]<='Z')){
    53             min=i;
    54             break;
    55             }
    56         }
    57     }
    58     switch(day){
    59         case 'A':printf("MON ");break;
    60         case 'B':printf("TUE ");break;
    61         case 'C':printf("WED ");break;
    62         case 'D':printf("THU ");break;
    63         case 'E':printf("FRI ");break;
    64         case 'F':printf("SAT ");break;
    65         case 'G':printf("SUN ");break;
    66     }
    67     switch(hh){
    68         case '0':printf("00:%02d",min);break;
    69         case '1':printf("01:%02d",min);break;
    70         case '2':printf("02:%02d",min);break;
    71         case '3':printf("03:%02d",min);break;
    72         case '4':printf("04:%02d",min);break;
    73         case '5':printf("05:%02d",min);break;
    74         case '6':printf("06:%02d",min);break;
    75         case '7':printf("07:%02d",min);break;
    76         case '8':printf("08:%02d",min);break;
    77         case '9':printf("09:%02d",min);break;
    78         case 'A':printf("10:%02d",min);break;
    79         case 'B':printf("11:%02d",min);break;
    80         case 'C':printf("12:%02d",min);break;
    81         case 'D':printf("13:%02d",min);break;
    82         case 'E':printf("14:%02d",min);break;
    83         case 'F':printf("15:%02d",min);break;
    84         case 'G':printf("16:%02d",min);break;
    85         case 'H':printf("17:%02d",min);break;
    86         case 'I':printf("18:%02d",min);break;
    87         case 'J':printf("19:%02d",min);break;
    88         case 'K':printf("20:%02d",min);break;
    89         case 'L':printf("21:%02d",min);break;
    90         case 'M':printf("22:%02d",min);break;
    91         case 'N':printf("23:%02d",min);break;
    92     }
    93     return 0;
    94 }
  • 相关阅读:
    矩形法求积分sin cos exp
    约瑟夫环问题
    KMP算法详解
    找出float型数组的最大值和最小值,分别和第一个和最后一个元素互换
    二重指针应用
    C++学习笔记(一)
    Line学习笔记
    node2vec学习笔记
    deepwalk学习笔记
    如何保证消息不被重复消费?(如何保证消息消费时的幂等性)
  • 原文地址:https://www.cnblogs.com/cutelife/p/11862664.html
Copyright © 2020-2023  润新知