* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio.pkg4;
import java.util.Scanner;
/**
*
* @author G ustavo Delgado Diaz de Leon
*/
public class Ejercicio4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long falta,numeroInvertido,resto;
System.out.println("Ingresa un numero");
long numero=sc.nextLong();
while(numero<=0);
falta=numero;
numeroInvertido=0;
resto=0;
resto=falta%10;
falta=falta/10;
numeroInvertido=numeroInvertido*10+resto;
while(falta!=0)
{
resto=falta%10;
numeroInvertido=numeroInvertido*10+resto;
falta=falta/10;
}
if(numeroInvertido==numero)
System.out.println("El numero es capicua\n");
else
System.out.println("El numero no es capicua\n");
// TODO code application logic here
}
}
No hay comentarios.:
Publicar un comentario