#include <stdio.h>
#include <string.h>
// Função recursiva para verificar se a palavra é palíndromo
int inverte(char *n, int tam, int posicao){
if (posicao < tam / 2){
if (n[posicao] == n[tam - posicao - 1]){
return 1 * inverte(n, tam, posicao+1);
}
else{
return 0;
}
}
else{
return 1;
}
}
int palindromo(char *n) {
int aux1, x = 0;
aux1
= inverte
(n
, strlen(n
), x
);
if (aux1
== 1) printf("Eh palindromo"); else printf("Nao eh palindromo");
}
int main() {
char m[30] = {"teste"};
palindromo(m);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCi8vIEZ1bsOnw6NvIHJlY3Vyc2l2YSBwYXJhIHZlcmlmaWNhciBzZSBhIHBhbGF2cmEgw6kgcGFsw61uZHJvbW8KaW50IGludmVydGUoY2hhciAqbiwgaW50IHRhbSwgaW50IHBvc2ljYW8pewoKCWlmIChwb3NpY2FvIDwgdGFtIC8gMil7CgkJaWYgKG5bcG9zaWNhb10gPT0gblt0YW0gLSBwb3NpY2FvIC0gMV0pewoJCQlyZXR1cm4gMSAqIGludmVydGUobiwgdGFtLCBwb3NpY2FvKzEpOwoJCX0KCQllbHNlewoJCQlyZXR1cm4gMDsKCQl9Cgl9CgllbHNlewoJCXJldHVybiAxOwoJfQp9CgppbnQgcGFsaW5kcm9tbyhjaGFyICpuKSB7IAoKICAgIGludCBhdXgxLCB4ID0gMDsKCQoJYXV4MSA9IGludmVydGUobiwgc3RybGVuKG4pLCB4KTsKCQogICAJaWYgKGF1eDEgPT0gMSkgcHJpbnRmKCJFaCBwYWxpbmRyb21vIik7CiAgICBlbHNlIHByaW50ZigiTmFvIGVoIHBhbGluZHJvbW8iKTsKICAgIAp9CgppbnQgbWFpbigpIHsKCQoJY2hhciBtWzMwXSA9IHsidGVzdGUifTsKICAgIHBhbGluZHJvbW8obSk7CgoJcmV0dXJuIDA7Cn0=