黄梓皓 • 17天前
#include<iostream>
using namespace std;
int main() {
int a1 = 0;
int a2 = 0;
int a3 = 0;
int x;
cin >> x;
if (x == 1) {
a1++;
}
if (x == 2) {
a2++;
}
if (x == 3) {
a3++;
}
int total = 1;
while (x != -1) {
cin >> x;
if (x != -1) {
total++;
}
if (x == 1) {
a1++;
}
if (x == 2) {
a2++;
}
if (x == 3) {
a3++;
}
}
cout << "A=" << a1 << endl;
cout << "B=" << a2 << endl;
cout << "C=" << a3 << endl;
cout << "Tot=" << total<<endl;
int j = total * 1.0 / 2;
if (a1 > j) {
cout << "A-yes";
}
if (a2 > j) {
cout << "B-yes";
}
if (a3 > j) {
cout << "C-yes";
}
if (a1&&a2&&a3 < j) {
cout << "all-NO";
}
return 0;
}
评论: