Created
October 5, 2010 06:42
-
-
Save 10851077/611133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean esPalindromo(String X){ | |
boolean palindromo; | |
String Y = ""; | |
String X2 = X.trim(); | |
for (int i =X2.length()-1;i>=0;i--) | |
Y = Y + X2.charAt(i); | |
if(Y.equalsIgnoreCase(X2)) | |
palindromo = true; | |
else | |
palindromo = false; | |
//System.out.println("X "+X); | |
//System.out.println("Y "+Y); | |
return palindromo; | |
} | |
public static void main(String[] args) { | |
Scanner entrada = new Scanner(System.in); | |
String Palabra; | |
System.out.println("Ingrese una cadena de caracteres: "); | |
Palabra = entrada.nextLine(); | |
System.out.println(esPalindromo(Palabra)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment