java判断回文数字
Here you will learn about number palindrome in java.
在这里,您将了解Java中的数字回文。
A number is called palindrome if it is equal to its reverse.
如果数字等于回文,则称为回文数。
For example 1221 is a palindrome while 1234 is not palindrome.
例如1221是回文,而1234不是回文。
Below I have shared the java program to check given number is palindrome or not.
下面我共享了Java程序来检查给定的编号是否为回文。
Also Read: String Palindrome in Java
Java数字回文程序 (Program for Number Palindrome in Java)
class Palindrome
{
public static void main(String...s)
{
int n,m,rev=0,i;
n=Integer.parseInt(s[0]);
m=n;
while(n!=0)
{
i=n%10;
rev=(rev*10)+i;
n/=10;
}
if(m==rev)
System.out.println("\nNumber is palindrome");
else
System.out.println("\nNumber is not palindrome");
}
}
Output
输出量
翻译自: https://www.thecrazyprogrammer.com/2013/08/java-program-to-check-whether-given.html
java判断回文数字