1033 旧键盘打字
题目链接-1033 旧键盘打字
解题思路
感觉是 题目链接-1019.旧键盘 的进阶版
感兴趣的可以去看看我的博客-1019.旧键盘
- 先判断一下坏掉的键中有没有’+’,如果有就用ass标记一下,就表示所有的大写字母都无法输出
- for循环遍历一遍b字符串,如果b[i]在a字符串中出现过就无法输出,如果b[i]是大写字母且’+'键坏掉了,则该字符也无法输出
归纳一下
isalnum
检测字符是否是英文字母或阿拉伯数字
isalpha()
检查字符是否是英文字母
isdigit()
检测字符是否为阿拉伯数字
isupper()
检测字符是否是大写字母
islower()
检测字符是否为小写字母
isspace()
检测字符是否为空格
toupper()
将小写字母转换成大写字母
tolower()
将大写字母转换成小写字母
附上代码
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
using namespace std;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=1e5+5;
typedef long long ll;
typedef pair<int,int> PII;
string a,b;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
getline(cin,a);
getline(cin,b);
bool ass=0;
if(a.find('+')!=string::npos)
ass=1;
for(int i=0;i<b.size();i++){
if(a.find(toupper(b[i]))!=string::npos)
continue;
if(isupper(b[i])&&ass)
continue;
else
cout<<b[i];
}
return 0;
}