PAT (Basic Level) Practise (中文)-1029. 旧键盘(20)

 

PAT (Basic Level) Practise (中文)-1029. 旧键盘(20)

http://www.patest.cn/contests/pat-b-practise/1029

 

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

输入格式:

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

输出格式:

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

输入样例:

7_This_is_a_test
_hs_s_a_es

输出样例:

7TI



 1 #include<stdio.h>
 2 
 3 void upper(char *str1)
 4 {
 5     int istr=0;
 6     while(str1[istr])
 7     {
 8         if('a'<=str1[istr] && str1[istr]<='z') 
 9              str1[istr]=str1[istr]-'a'+'A';
10         istr++;
11     }  
12 }
13  
14     
15 int main()
16 {
17     char tempchar=0,str[81],strprint[81],keys[128]={0};
18     gets(str);upper(str);
19     gets(strprint);upper(strprint);
20     
21     int istr=0,istrprint=0;
22     while(str[istr])
23     {
24             if(str[istr]==strprint[istrprint]) istrprint++;
25             else if(0==keys[str[istr]]) keys[str[istr]]=1,printf("%c",str[istr]);
26             istr++;
27     }
28     
29     return 0;
30 } 

 

posted on 2015-04-21 18:34  Asin_LZM  阅读(180)  评论(0编辑  收藏  举报