0
点赞
收藏
分享

微信扫一扫

[PAT乙] 1033 旧键盘打字 (20 分)

进击的铁雾 2022-02-21 阅读 35
算法

在这里插入图片描述

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
bool Hash[130]={false};
char str1[50],str2[100010];
int main(){
	int flag=0;
	cin.getline(str1,50);//坑:坏键可能为空!
	scanf("%s",str2);
	int len1=strlen(str1);
	int len2=strlen(str2);

	for(int i=0;i<len1;i++){
		Hash[str1[i]]=true;
	}
	
	for(int i=0;i<len2;i++){
		int temp=str2[i];
		if(temp>='a'&&temp<='z') temp-=32;
		if(Hash[temp]==false){//能够输出
			if(str2[i]>='A'&&str2[i]<='Z'&&Hash['+']==true){
				continue;
			}
			flag=1;//
			printf("%c",str2[i]);
		}
	}
	
	if(!flag) printf("\n");
}```

举报

相关推荐

0 条评论