处理字符串
题目 处理字符串
思路分析
根据前面总结
大小写用for+tolower/toupper
查找用find
把元音处理出来 用原串中每个字符在里面匹配
如果找到了元音不输出 如果不是元音 输出.+辅音字符
代码实现
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
cin>>s;
string vowel="aeiouy";
for(auto c:s){
c=tolower(c);
if(vowel.find(c)==-1)
cout<<'.'<<c;
}
return 0;
}
同类题型
视频讲解
⬅️ 基本操作 🏠 00-刷题理模型 ➡️ 大小写转换 字符串比较
💬 评论