题解 | #字符的个数#

字符的个数

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

#include<bits/stdc++.h>
#include <cstring>
using namespace std;
int main(){
    string s;
    cin>>s;
    // write your code here......
    
    //s.length()   s.size()
    int a = 0,b = 0,c = 0;
    for(int i = 0; i < std::strlen(s.c_str()); i++){
        if(s[i] == 'a'){
            a++;
        }
         if(s[i] == 'b'){
            b++;
        }
         if(s[i] == 'c'){
            c++;
        }
    }

    cout<< a<<" "<<b<<" "<< c;


    return 0;
}

全部评论

相关推荐

03-31 18:02
门头沟学院 Java
白日梦想家_等打包版:不要的哦佛给我
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务