1029 旧键盘

水题。与B1093 字符串A+B 类似。

#include<iostream>
#include<cctype>
using namespace std;
 
bool  hashtable[300] = {false};
int main() {
    string str1,str2;
    cin>>str1>>str2;
    for(int i = 0; i < str1.size(); ++i)//把str1,str2的小写字母转成大写字母
        if(islower(str1[i]))
            str1[i]-=32;
    for(int i = 0; i < str2.size(); ++i) {
        if(islower(str2[i]))
            str2[i]-=32;
        hashtable[str2[i]] = true; //标记非坏键 
    }
    for(int i = 0; i < str1.size(); ++i) {
        if(hashtable[str1[i]] == false) { 
            cout<<str1[i];//输出坏键
            hashtable[str1[i]] = true;//标记已访问 
        }
    }
    return 0;
}

 

posted @ 2020-02-18 12:05  tangq123  阅读(144)  评论(0编辑  收藏  举报