Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ejercicio10;
- import java.util.Scanner;
- public class Ejercicio10 {
- public static void main(String[] args) {
- Scanner sc= new Scanner(System.in);
- String pal;
- int j, i, cont;
- cont=0;
- i=0;
- System.out.println("Introduzca palabra: ");
- pal=sc.next();
- j = pal.length();
- while(i<j){
- for (j = pal.length()-1; j >= i; j--) {
- if(pal.charAt(i)==pal.charAt(j)){
- cont++;
- }
- i++;
- }
- }
- if(cont>=pal.length()/2){
- System.out.println("Es un palindromo");
- }else{
- System.out.println("No es palindromo");
- }
- }
- }
Add Comment
Please, Sign In to add comment