新型字符串病毒小程序

小明最近发现了一种新型字符串病毒,这种病毒的本体是一种字符串,且只由四种字符组成,'A','B','C','D'。且该病毒有一个特征,即字符'A'和字符'C'出现的次数均为偶数。只要符合这一特征,就可以认定其为病毒。现在小明一共有n个字符串,请帮忙判断是否为病毒,是则输出"Yes",否则输出“No”。
输入:
多组测试数据,第一行包含一个数n,表示字符串的个数
接下来n行每行包含一个字符串,表示你需要判断的字符串
输出:
对于每组数据,输出"Yes"或者"No"来表示该字符串是否为病毒。
样例输入:
3
CABD
BAAB
ACCDC
样例输出:

No
Yes
No


#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
int main()
{
    int n,countA,countC;
    cin >> n;
    string *str = new string[n];
    for(int i = 0;i < n;i++){
        cin >> str[i];
    }
    for(int i = 0;i < n;i++){
        countA = 0;
        countC = 0;
        for(int j = 0;j < str[i].length();j++){
            if(str[i][j] == 'A'){
                countA ++;
            }else if(str[i][j] == 'C'){
                countC ++;
            }
        }
        if(countA % 2 == 0 && countC % 2 == 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}
#include<iostream>
#include<cstring>
using namespace std;
char a[100];
int main() {
    int n,la,numA,numC;
    cin>>n;
    getchar();
    for(int i=1;i<=n;i++){
        numA=numC=0;
        cin.getline(a,100);
        la=strlen(a);
        for(int j=0;j<la;j++){
            if(a[j] == 'A') numA++;
            if(a[j] == 'C') numC++;
        }
        if(numA%2==0 && numC%2==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

countA=0 countC=0