题解 | #计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
getline(cin,str);
char ch = tolower(getchar());
int count = 0,i = 0;
while (i < str.size()) {
if (str[i] == ch) {
count++;
}
else if(str[i] == ch-32){
count++;
}
i++;
}
cout<<count<<endl;
}
// 64 位输出请用 printf("%lld")

巨人网络公司福利 91人发布