C++,无序关联容器unordered_multiset

计算某字母出现次数

http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

#include <iostream>
#include <string>
#include<unordered_set>
using namespace std;
int main()
{
    string s;
    getline(cin, s);
    char c;
    cin>>c;
    unordered_multiset<char> set;
    for (char c : s) {
        set.insert(tolower(c));
    }
    int n=set.count(tolower(c));
    cout << n << endl;
}

有两个c,感觉不妥的自己看着重命名一下吧。

全部评论

相关推荐

评论
8
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务