题解 | #字符的个数#

字符的个数

https://www.nowcoder.com/practice/dc28f2bf113a4058be888a5875206238

#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int a_num = 0, b_num = 0, c_num = 0;

    // write your code here......
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a')
            a_num = a_num + 1;
        else if (s[i] == 'b')
            b_num = b_num + 1;
        else if (s[i] == 'c')
            c_num = c_num + 1;
    }
    cout << a_num << " " << b_num << " " << c_num << endl;
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务