#include<bits/stdc++.h>
using namespace std;
int main() {
string str = "";
char target;
int ans = 0;
getline(cin, str);
cin >> target;
if(target >= 'A' && target <= 'Z') target = target - 'A' + 'a'; // 转小写
for(auto ch : str) {
if(ch == target) ans++;
else if(ch >= 'A' && ch <= 'Z' && ch - 'A' + 'a' == target) ans++;
}
printf("%d", ans);
return 0;
}
【华为笔试题 C++】HJ2 计算字符个数
最新推荐文章于 2024-07-10 18:02:44 发布