题解 | 数颜色

数颜色

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

#include <iostream>
using namespace std;

int main() {
    int R=0;
    int G=0;
    int B=0;
   string a;
   cin>>a;
   for(int i=0;i<size(a);i++)
   {
    if(a[i]=='R')R++;
    if(a[i]=='G')G++;
    if(a[i]=='B')B++;

   }
   cout<<"("<<R<<","<<G<<","<<B<<")";
   return 0;

}
//a.length() 或者 a.size() 来获取字符串的实际长度。
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

03-03 19:02
已编辑
东华理工大学 Node.js
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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