一定要注意失效票数也算在总票数里,最后是否过半不能看Tot

#include <bits/stdc++.h>
#define endl "\n";
using namespace std;
const int N = 100000;
int main()
{
    int n;
    int sum=0;
    int i=0;
    int J[N];
    while (cin >> n && n != -1)
    {
        J[i] = n;
        if (n == -1)
        {
            break;
        }
        i++;
    }
    int A = 0, B = 0, C = 0;
    for (int j = 0; j < i; j++)
    {
        if (J[j] == 1)
        {
            A++;
        }
        else if (J[j] == 2)
        {
            B++;
        }
        else if (J[j] == 3)
        {
            C++;
        }
    }
sum=A+C+B;
    cout << "A=" << A << endl;
    cout << "B=" << B << endl;
    cout << "C=" << C << endl;
    cout << "Tot=" << sum << endl;
    int YES = max(A, max(B, C));
    if (YES > i / 2)
    {
        if (YES == A)
        {
            cout << "A-yes";
        }
        if (YES == B)
        {
            cout << "B-yes";
        }
        else if(YES==C)
        {
            cout << "C-yes";
        } 
    }
    else{
            cout<<"all-NO";
        }
}