题解 | 字符的个数
字符的个数
https://www.nowcoder.com/practice/dc28f2bf113a4058be888a5875206238
#include<bits/stdc++.h>
#include <string>
using namespace std;
int main(){
string s;
cin>>s;
// write your code here......
int a_count = 0, b_count = 0, c_count;
for (int i = 0; i < s.size(); i ++) {
if (s[i] == 'a')
a_count ++;
else if (s[i] == 'b')
b_count ++;
else if (s[i] == 'c')
c_count ++;
}
cout << a_count << " " << b_count << " " << c_count;
return 0;
}

查看3道真题和解析