标签:contains enc and out keyboard asc cas oar letters
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
hssaes
输入s1(应该输入的字符串),s2(显示出来的字符串),判断键盘坏掉的键
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char * argv[]) {
char s1[81],s2[81];
cin.getline(s1,81);
cin.getline(s2,81);
int asc[256]= {0},bk[256]= {0};
int len1=strlen(s1),len2=strlen(s2);
for(int i=0; i<len2; i++) {
asc[toupper(s2[i])]++;
}
for(int i=0; i<len1; i++) {
char temp = toupper(s1[i]);
if(asc[temp]==0&&bk[temp]==0){
printf("%c",temp);
bk[temp]=1;
}
}
return 0;
}
PAT Advanced 1050 Broken Keyboard (20) [Hash散列]
标签:contains enc and out keyboard asc cas oar letters
原文地址:https://www.cnblogs.com/houzm/p/12238782.html