首页 > 其他分享 >判断回文数

判断回文数

时间:2023-01-27 16:44:06浏览次数:41  
标签:10 判断 Scanner No int System 回文

判断回文数

输入一个大于0的整数x,

若x是回文数,则输出Yes,否则输出No

import java.util.Scanner;


public class PalindromicNumber {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();

        int t = x, y = 0;
        while (t != 0) {
            y = y * 10 + (t % 10);
            t /= 10;
        }

        if (x == y) System.out.println("Yes");
        else System.out.println("No");
    }
}

标签:10,判断,Scanner,No,int,System,回文
From: https://www.cnblogs.com/aruhan/p/17069013.html

相关文章