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

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

    输入格式:

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

    输出格式:

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

    输入样例:

    7_This_is_a_test
    _hs_s_a_es
    

    输出样例:

    7TI
    
     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<math.h>
     4 #include<stdlib.h>
     5 #include<ctype.h>
     6 int main(){
     7     char a[200];
     8     char b[200];
     9     gets(a);
    10     gets(b);
    11     int lena = strlen(a);
    12     int lenb = strlen(b);
    13     for(int i=0;i<lena;i++){
    14         a[i] = toupper(a[i]);
    15     } 
    16     for(int i=0;i<lenb;i++){
    17         b[i] = toupper(b[i]);
    18     } 
    19     int d[300]={0};
    20     for(int i=0;i<lenb;i++){
    21         d[b[i]] = 1;
    22     }
    23     for(int i=0;i<lena;i++){
    24         if(d[a[i]]==0){
    25             printf("%c",a[i]);
    26             d[a[i]] = 1;
    27         }
    28         
    29     }
    30 }
  • 相关阅读:
    94. Binary Tree Inorder Traversal
    101. Symmetric Tree
    38. Count and Say
    28. Implement strStr()
    实训团队心得(1)
    探索性测试入门
    LC.278. First Bad Version
    Search in Unknown Sized Sorted Array
    LC.88. Merge Sorted Array
    LC.283.Move Zeroes
  • 原文地址:https://www.cnblogs.com/lolybj/p/6197073.html
Copyright © 2011-2022 走看看