Advertisement
Leticia22

Palindromo1

Mar 27th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define M 100
  5.  
  6. /*8.Implementar una función recursiva en C que permita determinar si un arreglo de números enteros es
  7. palíndromo o no. No podrá usar arreglos adicionales y la función solo podrá recibir dos parámetros:
  8. el arreglo y su longitud
  9.  *
  10.  */
  11.  
  12. int EsPalindromo(char V[],int fin){
  13.      int i=0;
  14.     if(i>=fin)
  15.         return 1;
  16.       if (V[strlen(V)-fin-1]==V[fin]){
  17.         return EsPalindromo(V, fin-1);
  18.     }
  19.    
  20.     else
  21.         return 0;  
  22. }
  23.  
  24. int main(int argc, char** argv) {
  25.     int EP;
  26.     char V[]="ANITALAVALATINAL";
  27.    
  28.     int n = strlen(V);
  29.     EP=EsPalindromo(V,n-1);
  30.     if (EP==1)
  31.         printf("La palabra es palindromo");
  32.     else
  33.         printf("La palabra no es palindromo");
  34.     return (EXIT_SUCCESS);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement