PAT (Basic Level) Practice 1029 旧键盘
2019-01-23 10:43
253 查看
版权声明:copyright©CodeIover reserved https://blog.csdn.net/qq_40073459/article/details/86606048
1029 旧键盘
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。
输入格式:
输入在 2 行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过 80 个字符的串,由字母 A-Z(包括大、小写)、数字 0-9、以及下划线
_(代表空格)组成。题目保证 2 个字符串均非空。
输出格式:
按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有 1 个坏键。
输入样例:
[code]7_This_is_a_test _hs_s_a_es
输出样例:
[code]7TI
实现代码:
[code]#include<stdio.h> #include<string.h> #include<stdbool.h> int main() { char str1[100],str2[100]; bool HashTable[128]={false}; gets(str1); gets(str2); int len1=strlen(str1); int len2=strlen(str2); for(int i=0;i<len1;i++) { int j; char c1,c2; for(j=0;j<len2;j++) { c1=str1[i]; c2=str2[j]; if(c1>='a'&&c1<='z') c1-=32; if(c2>='a'&&c2<='z') c2-=32; if(c1==c2) break; } if(j==len2&&HashTable[c1]==false) { printf("%c",c1); HashTable[c1]=true; } } return 0; }
结果如下:
相关文章推荐
- PAT (Basic Level) Practice 1029 旧键盘(20)(C语言实现)
- Pat(Basic Level)Practice--1029(旧键盘)
- PAT (Basic Level) Practise (中文)-1029. 旧键盘(20)
- PAT (Basic Level) Practise (中文)1029. 旧键盘(20) C语言
- PAT (Basic Level)1029. 旧键盘
- PAT(basic level) 1029 旧键盘(20)
- PAT BASIC LEVEL 1029. 旧键盘(20)
- PAT Basic Level 1029 旧键盘 (20 分)
- PAT (Basic Level) Practise (中文)1029. 旧键盘(20)
- PAT (Basic Level) Practice 1033 旧键盘打字
- PAT(Basic Level)_1029_旧键盘
- Pat(Basic Level)Practice--1033(旧键盘打字)
- PAT (Basic Level) Practise (中文)1029. 旧键盘(20)
- PAT (Basic Level) Practise (中文)1029. 旧键盘(20)
- PAT (Basic Level) Practise (中文) 1029. 旧键盘(20)
- PAT (Basic Level) Practise:1029. 旧键盘
- 【PAT】(Basic Level) Practise (中文)1029. 旧键盘(20)
- Pat(Basic Level)Practice--1038(统计同成绩学生)
- Pat(Basic Level)Practice--1001(害死人不偿命的3n+1猜想)
- PAT (Basic Level) Practice (中文)-1004