zoukankan      html  css  js  c++  java
  • PAT乙级 1029. 旧键盘(20)

    1029. 旧键盘(20)

    时间限制
    200 ms
    内存限制
    65536 kB
    代码长度限制
    8000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。

    输入格式:

    输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。

    输出格式:

    按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有1个坏键。

    输入样例:
    7_This_is_a_test
    _hs_s_a_es
    
    输出样例:
    7TI
    

     版本一:

    坏键的输入顺序是根据0-9 a-z的顺序输入

    不符合题意

    题意是按照输入顺序输出

     1 #include "stdio.h"
     2 #include"string.h"
     3 int main()
     4 {
     5   int keybord[37]={0};
     6   char temp;
     7     int i;
     8   while(1)
     9   {
    10     temp=getchar();
    11     if (temp=='
    ')
    12     break;
    13     if(temp<='9'&&temp>='0')
    14     keybord[temp-'0']=1;
    15     if(temp<='z'&&temp>='a')
    16     keybord[temp-'a'+10]=1;
    17     if(temp<='Z'&&temp>='A')
    18     keybord[temp-'A'+10]=1;
    19       if(temp=='_')
    20     keybord[36]=1;
    21   }
    22     while(1)
    23   {
    24       temp=getchar();
    25     if (temp=='
    ')
    26     break;
    27     if(temp<='9'&&temp>='0')
    28     keybord[temp-'0']=0;
    29     if(temp<='z'&&temp>='a')
    30     keybord[temp-'a'+10]=0;
    31     if(temp<='Z'&&temp>='A')
    32     keybord[temp-'A'+10]=0;
    33       if(temp=='_')
    34     keybord[36]=0;
    35     }
    36 
    37     for(i=0;i<37;i++)
    38     {
    39     ;
    40       if(keybord[i])
    41       {  
    42         if (i>=0&&i<=9)printf("%c",i+'0' );  
    43         if (i>=10&&i<=35)printf("%c",'A'+i-10 );
    44         if(temp=='_') printf("_" );    
    45   
    46     } 
    47     }
    48 
    49   return 0;
    50 }

    版本二:

     1 #include "stdio.h"
     2 #include"string.h"
     3 int main()
     4 {
     5   int len_a=0,len_b=0;
     6   char c1,c2;
     7     int j,i,keybord[150]={0};
     8   char a[81],b[81];
     9   gets(a);
    10     gets(b);
    11   len_a=strlen(a);
    12   len_b=strlen(b);
    13   for(i=0;i<len_a;i++)
    14   {
    15     c1=a[i];
    16     for(j=0;j<len_b;j++)
    17     {
    18       c2=b[j];
    19       if(c1 >= 'a' && c1 <= 'z')
    20                 c1 = c1 + 'A' - 'a';
    21            if(c2 >= 'a' && c2 <= 'z')
    22                 c2 = c2 + 'A' - 'a';
    23        if(c1==c2)
    24          break;
    25 
    26     }
    27     if(j==len_b&&keybord[c1]==0)
    28     {
    29       printf("%c",c1);
    30       keybord[c1]=1;
    31     }
    32 
    33   }
    34 
    35   return 0;
    36 }
  • 相关阅读:
    python ratelimit使用
    团队怎样去做技术规划
    分词语义提取工具
    今日头条推荐系统
    要选择做有价值的事情
    总结与规划
    性能使用到极限
    流量运营
    Stanford CoreNLP使用需要注意的一点
    七年总结
  • 原文地址:https://www.cnblogs.com/zle1992/p/5956474.html
Copyright © 2011-2022 走看看