1029. 旧键盘

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
 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 #include<string.h>
 5 #include<algorithm>
 6 using namespace std;
 7 
 8 int main()
 9 {
10     int hashtable[150] = {};
11     int i, j, len1, len2;
12     char s1[100], s2[100];
13     gets(s1);
14     gets(s2);
15     len1 = strlen(s1);
16     len2 = strlen(s2);
17     for(i = 0; i < len1; i++)
18     {
19         char c1 = s1[i];
20         for(j = 0; j < len2; j++)
21         {
22             char c2 = s2[j];
23             if(c1 >= 'a' && c1 <= 'z')
24                 c1 = c1 + 'A' - 'a';
25             if(c2 >= 'a' && c2 <= 'z')
26                 c2 = c2 + 'A' - 'a';
27             if(c1 == c2)
28             {
29                 break;
30             }
31         }
32         if(j == len2 && hashtable[c1] == 0)
33         {
34             printf("%c", c1);
35             hashtable[c1] = 1;
36         }
37     }
38     printf("
");
39     return 0;
40 }
原文地址:https://www.cnblogs.com/yomman/p/4284314.html