题解 | #计算某字符出现次数#
计算某字符出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
- 字符串尽量的使用getline方法
- toupper 大小写统一
using namespace std;
int main()
{
string str;
char word;
getline(cin,str);
cin>>word;
unordered_multiset<char> mulset;
for(int i=0;i<str.length();i++)
{
mulset.insert(toupper(str[i]));
}
cout<<mulset.count(toupper(word));
return 0;
}

查看21道真题和解析