📜  java代码示例中的回文

📅  最后修改于: 2022-03-11 14:52:12.453000             🧑  作者: Mango

代码示例4
package com.candidjava; import java.util.Scanner; public class PalindromeUptoN{    public static void main(String[] args)    {        int n, b, rev = 0;        Scanner sc = new Scanner(System.in);        System.out.println("Enter the Palindrome No N:");        int N = sc.nextInt();        System.out.print("Palindrome numbers from 1 to N:");        for (int i = 1; i <= N; i++)        {            n = i;            while (n > 0)            {                b = n % 10;                rev = rev * 10 + b;                n = n / 10;            }            if (rev == i)            {                System.out.print(i + " ");            }            rev = 0;        }    } }