HJ2 计算某字符出现次数
文章目录
- 题目
- 实现代码
- 运行结果
题目
实现代码
#include <cctype>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;int main() {unordered_map<char, int> mp;string input;getline(cin, input);for(auto c: input) {if(isdigit(c)) {mp[c]++;} else if(isalpha(c)) {mp[tolower(c)]++;}}char c;cin >> c;cout << mp[tolower(c)]<< endl;
}
// 64 位输出请用 printf("%lld")
运行结果
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!