#include <stdio.h> #include <stdlib.h> //解法三 int main() { char ch = 0; int flag = 0; while (((ch = getchar()) != '0') && ch != EOF) { if (ch == 'A') { flag++; } else if (ch == 'B') { flag--; } } if (flag > 0) { printf("A\n"); } else if (flag < 0) { printf("B\n"); } else if (flag == 0) { printf("E\n"); } return 0; } /* //解法二: int main() { int flag = 0; char arr[100] = { 0 }; gets_s(arr, 100); int i = 0; while (arr[i] != '0') { if (arr[i] == 'A') { flag++; } else if (arr[i] == 'B') { flag--; } i++; } if (flag < 0) { printf("B\n"); } else if (flag == 0) { printf("E\n"); } else { printf("A\n"); } return 0; } */ /* //解法一: int main() { //用于记录A,B的票数 int count_a = 0; int count_b = 0; char arr[100] = { 0 }; //输入 gets_s(arr, 100); int i = 0; while (arr[i] != '0') { if (arr[i] == 'A') { count_a++; } else if (arr[i] == 'B') { count_b++; } i++; } if (count_a > count_b) { printf("A\n"); } else if (count_a < count_b) { printf("B\n"); } else { printf("E\n"); } return 0; } */