题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
#include <iostream> #include <string> #include <unordered_map> using namespace std; int main(int, char **) { unordered_map<char, int> map; string input;//带空格的输入字符串 getline(cin,input);//getline可以带空格 char target; cin >> target; for (auto i : input) { ++map[tolower(i)]; } cout << map[tolower(target)] << endl; }