题解 | #竞选社长#
竞选社长
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; }