题解 | #字符的个数#

字符的个数

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

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    // write your code here......
    int a=0;
    int b=0;
    int c=0;
    for(char i:s)
    {
        switch(i)
        {
            case 'a':a++;break;
            case 'b':b++;break;
            case 'c':c++;
        }
    }
    cout<<a<<' '<<b<<' '<<c<<endl;
    return 0;
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务