向量中元素和为15递归

在不改变函数主体的情况下求向量中所有和为15的元素次数,我发现子向量会重复计算

int listAllFifteens(Vector & cards) {
    // TODO: Delete this line and the next two lines, then implement this wrapper function.
    int sum=0;
    Vector<int> a={0,0,0,0,0};
    int len=cards.size();
    for(int i=0;isum+=currentcard.getRank();

    }
    if (sum<=15) {
        return sum==15 ?1:0;
    }else {

        for(int j=0;j0];
            cards.remove(0);
            a[j]=listAllFifteens(cards);

            cards.add(x);
        }

    }
    return a[0]+a[1]+a[2]+a[3]+a[4];
}