题解 | 竞选社长
竞选社长
https://www.nowcoder.com/practice/45a30e3ef51040ed8a7674984d6d1553
#include <stdio.h> int main() { char arr[20] = {0}; scanf("%s",arr); int i = 0; int count1 = 0; int count2 = 0; int flag = 1; while(flag) { if(arr[i] == '0') { flag = 0; break; } if(arr[i] == 'A') { count1++; } else if (arr[i] == 'B') { count2++; } i++; } if(count1 > count2) { printf("A"); } else if(count2 > count1) { printf("B"); } else { printf("E"); } return 0; }