题解 | C++#计算某字符出现次数#
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
while (getline(cin, s)) {
char c;
cin >> c;
c = tolower(c);
int n = s.size();
int cnt = 0;
for (int i = 0; i < n; ++i) {
if (tolower(s[i]) == c) {
++cnt;
}
}
cout << cnt << endl;
getchar();
}
}
// 64 位输出请用 printf("%lld")


深信服公司福利 797人发布