字會是怎樣?
輸入描述:
輸入在2行中分別給出壞掉的那些鍵、以及應該輸入的文字。其中對應英文字母的壞鍵以大寫給出;每段文字是不超過10^5個字符的串。可用的
字符包括字母[a-z, A-Z]、數字0-9、以及下劃線“_”(代表空格)、“,”、“.”、“-”、“+”(代表上檔鍵)。題目保證第2行輸入的文字串非空。
注意:如果上檔鍵壞掉了,那麼大寫的英文字母無法被打出。
輸出描述:
在一行中輸出能夠被打出的結果文字。如果沒有一個字符能被打出,則輸出空行。
輸入例子:
7+IE.
7_This_is_a_test.
輸出例子:
_hs_s_a_tst
#include<stdio.h>
#include<string.h>
#define MAXSIZE 100000+1
char ch[MAXSIZE]={0};
int broken_ch[256]={0};
void brokenKeyboard(){
char wrongkey[50];
scanf("%s %s",wrongkey,ch);
int len_wrongkey=strlen(wrongkey);
int len_ch = strlen(ch);
for(int i=0;i<len_wrongkey;i++){
broken_ch[wrongkey[i]-'0']=1;
}
for(int i=0;i<len_ch;i++){
if((ch[i]>='A'&&ch[i]<='Z')){
if((broken_ch[ch[i]-'0']==0)&&(broken_ch['+'-'0']==0))
printf("%c",ch[i]);
}else if((ch[i]>='a'&& ch[i]<='z')){
if((broken_ch[ch[i]-'0'+'A'-'a']==0))
printf("%c",ch[i]);
}else{
if(broken_ch[ch[i]-'0']==0)
printf("%c",ch[i]);
}
}
}
int main()
{
brokenKeyboard();
return 0;
}