I have a question with exercise of batteries that I found, in this exercise, it looks for how many times a letter is repeated and also returns the number of letters that are in an even position.
I have several doubts, one of them is in this part:
What are you doing there?
while(!pila.empty()){
par=!par;//por cada letra pasa a ser impar, par
pila.pop();
}
What do you want to do with the instruction par=!par
and then pila.pop();
?
bool letrapar (char palabra[], char letra, stack_l_t<char> pila){
bool par=true;
int i=0;
int l=strlen(palabra);
while(i<l){
if(letra==palabra[i])
pila.push(palabra[i]);//meto las letras que busco en la pila, o eso entiendo
i++;
}
while(!pila.empty()){
par=!par;//por cada letra pasa a ser impar, par
pila.pop();
}
return par;
}