java判断回文数字_Java中的数字回文

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中的字符串回文

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

输出量

Java program to check whether a given number is palindrome or not

翻译自: https://www.thecrazyprogrammer.com/2013/08/java-program-to-check-whether-given.html

java判断回文数字

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值