题解 | #竞选社长#

竞选社长

https://www.nowcoder.com/practice/45a30e3ef51040ed8a7674984d6d1553

#include <iostream>
using namespace std;

int main() {

    string str;
    cin>>str;

    int cnt_a=0;
    int cnt_b=0;
    
    for(int i=0; str[i]!='0'; i++){
        if(str[i] == 'A')
            cnt_a++;
        else if(str[i] == 'B'){
            cnt_b++;
        }
    }



    if(cnt_a>cnt_b)
        cout<<"A"<<endl;
    else if(cnt_a == cnt_b)
        cout<<"E"<<endl;
    else if(cnt_a <cnt_b)
        cout<<"B"<<endl;




return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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