PAT(散列)——1084. Broken Keyboard (20)

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
Sample Output:
7TI

题目大意:

签到题。

题目解析:

具体代码:

#include<iostream>
#include<map>
#include<ctype.h>
using namespace std;
map<char,int> m;
map<char,int> temp;

int main() {
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<s2.size();i++){
		if(s2[i]>='a'&&s2[i]<='z')
			s2[i]=toupper(s2[i]);
		m[s2[i]]=1;
	}
	for(int i=0;i<s1.size();i++){
		if(s1[i]>='a'&&s1[i]<='z')
			s1[i]=toupper(s1[i]);
		if(m.find(s1[i])==m.end()&&temp.find(s1[i])==temp.end()){
			printf("%c",s1[i]);
			temp[s1[i]]=1;
		}
	}
	return 0;
}
全部评论

相关推荐

ProMonkey2024:5个oc?厉害! 但是有一个小问题:谁问你了?😡我的意思是,谁在意?我告诉你,根本没人问你,在我们之中0人问了你,我把所有问你的人都请来 party 了,到场人数是0个人,誰问你了?WHO ASKED?谁问汝矣?誰があなたに聞きましたか?누가 물어봤어?我爬上了珠穆朗玛峰也没找到谁问你了,我刚刚潜入了世界上最大的射电望远镜也没开到那个问你的人的盒,在找到谁问你之前我连癌症的解药都发明了出来,我开了最大距离渲染也没找到谁问你了我活在这个被辐射蹂躏了多年的破碎世界的坟墓里目睹全球核战争把人类文明毁灭也没见到谁问你了(别的帖子偷来的,现学现卖😋)
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务