0
How do I multiply the elements of an array? what am I doing wrong?
For example, if I have:
int numbers[]={1,2,2,4,5,6};
and my card_block is 2, the restutado would 1x4x5x6=120;
int countCards(int [] cards, int BLOCK_CARD){
int quant=0;
int count =0;
for (int i=0; i<cards.length; i++){
if(cards[i]!=BLOCK_CARD)
count=cards[i];
count=count*cards[i];
quant=count;
}
return quant;
}
What logic are you trying to apply ? Each time you are on the blocked card you are supposed to multiply by the last before the blocked one or simply ignore the card ?
– Isac