On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.
Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.
Input Specification:
Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or "_" (representing the space). It is guaranteed that both strings are non-empty.
Output Specification:
For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.
Sample Input:
7_This_is_a_test _hs_s_a_es
Sample Output:
7TI 思路:本题可以借鉴的地方是Harsh一共开了128个单元。 足以涵盖任何字符。 并且此题有一处需要注意,最后的while循环不要省略
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 bool Harsh[128]={false}; 6 void Print(char ch) 7 { 8 if(ch>=‘a‘&&ch<=‘z‘) 9 ch-=32; 10 if(!Harsh[ch]) 11 { 12 13 putchar(ch); 14 } 15 Harsh[ch]=true; 16 } 17 18 int main(int argc, char *argv[]) 19 { 20 char ori[85]; 21 char now[85]; 22 scanf("%s %s",ori,now); 23 int i,j; 24 for(i=0,j=0;ori[i]!=‘\0‘&&now[j]!=‘\0‘;) 25 { 26 if(ori[i]!=now[j]) 27 { 28 Print(ori[i]); 29 i++; 30 } 31 else 32 { 33 i++; 34 j++; 35 } 36 } 37 while(ori[i]!=‘\0‘) 38 Print(ori[i++]); 39 putchar(‘\n‘); 40 41 return 0; 42 }