PAT乙级 (1033 旧键盘打字 (20分)(字母大小写转换、判断是否为大小写字母数字))
1033 旧键盘打字 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805288530460672
字母的大小写转换:(头文件:#include <cctype>)
小写转大写:toupper()
大写转小写:tolower()
判断:
是否为字母: isalpha()
是否为数字: isdigit()
是否为大写字母: isupper()
是否为小写字母: islower()
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
int main()
{
string str1,str2;
getline(cin,str1);
getline(cin,str2);
for(int i=0;i<str2.length();i++)
{
if(str1.find(toupper(str2[i]))!=string::npos) continue;
if((isupper(str2[i]))&&(str1.find('+')!=string::npos)) continue;
cout<<str2[i];
}
return 0;
}
天晴了,起飞吧

浙公网安备 33010602011771号