fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4.  
  5. int inverte (char *n, int y, int aux) {
  6. if (y <= aux) return 1;
  7. else {
  8. if (n[y - 1] != n[aux]) return 0;
  9.  
  10. return inverte(n, y-1, aux+1);
  11. }
  12. }
  13.  
  14. int palindromo (char *n) {
  15. int aux1, x = 0;
  16.  
  17. aux1 = inverte(n, strlen(n), x);
  18.  
  19. if (aux1 == 1) printf("Eh palindromo\n");
  20. else printf("Nao eh palindromo\n");
  21.  
  22. }
  23.  
  24.  
  25. int main() {
  26. palindromo("banana");
  27. palindromo("anna");
  28. palindromo("ana");
  29. palindromo("bananab");
  30. palindromo("aa");
  31. palindromo("a");
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
Nao eh palindromo
Eh palindromo
Eh palindromo
Eh palindromo
Eh palindromo
Eh palindromo