题解 | 数颜色

数颜色

https://www.nowcoder.com/practice/7f458453debe49c9a98f20f42d65ebf1

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
    char ch[100005];
    scanf("%s", ch);

    int len = strlen(ch);
    int count_r = 0, count_g = 0, count_b = 0;
    for(int i = 0; i < len; i++){
        if(ch[i] == 'R')  count_r++;
        else if(ch[i] == 'G')  count_g++;
        else  count_b++;
    }
    printf("(%d,%d,%d)", count_r, count_g, count_b);
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
对空六翼:你真幸运,碰见这么好的人,不像我,秋招的时候被室友骗进cx了
实习好累,可以辞职全力准...
点赞 评论 收藏
分享
求问!考研下岸,打算参加春招,我这个bg能进啥厂,或者需要搞点深度项目再投吗
Java抽象带篮子_...:直接海投,可以看看我的考研失利速成冲春招贴,里面详细写了简历怎么写,学哪些项目可以速成
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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