代码如下
#include <iostream>
using namespace std;
int cnt[4] = {0}, tot = 0, num;
int main() {
cin >> num;
while (num != -1) {
if (num >=1 && num <= 3) {
tot++;
cnt[num]++;
}
cin >> num;
}
bool flag = false; int half;
if (tot % 2 == 0) half = tot / 2;
else half = tot / 2 + 1;
for (int i = 1; i <= 3; i++)
cout << char(64+i) << '=' << cnt[i] << endl;
cout << "Tot=" << tot << endl;
for (int i = 1; i <= 3; i++)
if (cnt[i] > half) {
cout << char(64+i) << "-yes" << endl;
flag = true;
}
if (flag == false) cout << "all-NO" << endl;
return 0;
}