1033. 旧键盘打字(20)
生活随笔
收集整理的這篇文章主要介紹了
1033. 旧键盘打字(20)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
舊鍵盤上壞了幾個鍵,于是在敲一段文字的時候,對應的字符就不會出現。現在給出應該輸入的一段文字、以及壞掉的那些鍵,打出的結果文字會是怎樣?
輸入格式:
輸入在2行中分別給出壞掉的那些鍵、以及應該輸入的文字。其中對應英文字母的壞鍵以大寫給出;每段文字是不超過105個字符的串。可用的字符包括字母[a-z, A-Z]、數字0-9、以及下劃線“_”(代表空格)、“,”、“.”、“-”、“+”(代表上檔鍵)。題目保證第2行輸入的文字串非空。
注意:如果上檔鍵壞掉了,那么大寫的英文字母無法被打出。
輸出格式:
在一行中輸出能夠被打出的結果文字。如果沒有一個字符能被打出,則輸出空行。
輸入樣例:
7+IE. 7_This_is_a_test.輸出樣例:
_hs_s_a_tst #include<cstdio> #include<cstring> const int maxn = 100010; char str[maxn]; bool HashTable[256]; int main(){memset(HashTable,true,sizeof(HashTable));gets(str);int len = strlen(str);for(int i = 0; i < len; i++){if(str[i] >= 'A' && str[i] <= 'Z'){str[i] = str[i] - 'A' + 'a';}HashTable[str[i]] = false;}gets(str);len = strlen(str);for(int i = 0; i < len; i++){if(str[i] >= 'A' && str[i] <= 'Z'){int low = str[i] - 'A' + 'a';if(HashTable[low] == true && HashTable['+']==true){printf("%c",str[i]);}}else if(HashTable[str[i]] == true){printf("%c",str[i]);}}printf("\n");return 0; }?
//第三個測試點未通過,待驗證 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int maxn = 100010;int main(){bool hashTable[270];memset(hashTable,true,sizeof(hashTable)); char str1[maxn],str2[maxn];cin >> str1 >> str2;int len1 = strlen(str1);int len2 = strlen(str2);for(int i = 0 ; i < len1; i++){if(str1[i] >= 'A' && str1[i] <= 'Z')str1[i] = str1[i] - 'A' + 'a';hashTable[str1[i]] = false;}bool flag = false;for(int i = 0; i < len2; i++){if(str2[i] >= 'A' && str2[i] <= 'Z'){int low = str2[i] - 'A' + 'a';if(hashTable['+'] == true && hashTable[low] == true){printf("%c",str2[i]);flag = true;} }else if(hashTable[str2[i]] == true){printf("%c",str2[i]);flag = true;} }if(!flag) printf("\n"); return 0; }?
轉載于:https://www.cnblogs.com/wanghao-boke/p/8644802.html
總結
以上是生活随笔為你收集整理的1033. 旧键盘打字(20)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成都欢乐谷必须刷身份证吗
- 下一篇: 英雄联盟全英雄全皮肤全符文和全符文页,多