错误原因到底在哪里?

徐teacher的小本子上有、n个数字,而徐teacher觉得如果一个数字每一位上的数字和是、6的倍数,那么这个数 字是幸运的。
徐teacher想知道他的小本子上有多少个幸运数字?

#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<string>
using namespace std;
int a[101];
bool ws(int n){
    int a=0;
    while(n!=0){
        a+=n%10;
        n/=10;
    }
    if(a%6==0){
        return 1;
    }
    return 0;
}
int main(){
    int n,c=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(ws(a[i])){
            c++;
        }
    }
    cout<<c;
    return 0;
}

请问哪里错了?

我执行能得到正确结果。你遇到什么问题了?
输入:
3
42
33
23
输出:
2