题解 | #字符的个数#

字符的个数

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

#include <iostream>
#include<string>
using namespace std;
int main(){
    char str[1000000];
    cin.getline(str,sizeof(str));
    // write your code here......
    int a,b,c;
    a=0;
    b=0;
    c=0;
    char *p =str;
    while(*p !='\0'  ){
        if(*p=='a')
        a++;
        else if(*p=='b')
        b++;
        else ++c;
        p++;
    }
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}

全部评论

相关推荐

明日Star:第一个项目修一修,点不用多3-4个,描述就是优化+指标量化。第二个项目换一下吧,换个agent
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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