题解 | #竞选社长#

竞选社长

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

#include <iostream>
using namespace std;

int main() {
    char res[50] = {0};
    cin >> res;
    int hash[2]={0};
    int i=0;
    while(res[i]!='0')
    {
        if(res[i]=='A')
        {
            hash[0]++;
        }else if(res[i]=='B'){
            hash[1]++;
        }
        i++;
    }
    if(hash[0] > hash[1])
    {
        cout << "A"<<endl;
    }else if(hash[0] < hash[1]){
         cout << "B"<<endl;
    }else
        cout << "E" << endl;
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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