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