package palindrome.in.java;
import java.util.Scanner;
public class PalinDromeInJava {
public class PalinDromeInJava {
public static void main(String[] args) {
// TODO code application logic here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int rem, temp, sum = 0;
// TODO code application logic here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int rem, temp, sum = 0;
temp = n;
while (n > 0) {
rem = n % 10;
n = n / 10;
sum = (sum * 10) + rem;
while (n > 0) {
rem = n % 10;
n = n / 10;
sum = (sum * 10) + rem;
}
if (temp == sum) {
if (temp == sum) {
System.out.println(“palindrome”);
} else {
System.out.println(“non palindrome”);
}
}
}
} else {
System.out.println(“non palindrome”);
}
}
}
OUTPUT
121
palindrome
/** but only for numbers this method is applicable
by digit addition and then tenth digit addition and so on it is done!
**/
No comments:
Post a Comment