A1084 Broken Keyboard [散列]

在这里插入图片描述
题目大意:检测哪个按键坏了

#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string s1, s2;
	bool hashtable[128] = { false };
	bool isput[128] = { false };
	getline(cin,s1);
	getline(cin, s2);
	int len1 = s1.length();
	int len2 = s2.length();
	for (int i = 0; i < len2; i++)
	{
		if (s2[i] >= 'a' && s2[i] <= 'z')
		{
			s2[i] -= 32;
		}
		if (hashtable[s2[i]] == false)
		{
			hashtable[s2[i]] = true;
		}
	}
	for (int i = 0; i < len1; i++)
	{
		if (s1[i] >= 'a' && s1[i] <= 'z')
		{
			s1[i] -= 32;
		}
		if (hashtable[s1[i]] == false&&isput[s1[i]]==false)
		{
			cout << s1[i];
			isput[s1[i]] =true;
		}
	}
	return 0;
}
posted @ 2020-07-05 15:20  _Hsiung  阅读(37)  评论(0编辑  收藏  举报