题解 | 数颜色

数颜色

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

#include <iostream>
#include<string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r=0,g=0,b=0;
    string s;
    cin>>s;
    for(char c:s){
        if(c=='R')r++;
        if(c=='G')g++;
        if(c=='B')b++;
    }
    cout<<"("<<r<<","<<g<<","<<b<<")\n";
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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