一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同,用java代码描述

import java.util.Scanner;

public class exercise_719_11 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

		try {
			System.out.println("请输入一个五位数");
			int num = sc.nextInt();
			if (num>=10000 &&num<100000) {
				int gw = num % 10;
				int sw = num % 100 / 10;
				int qw = num / 1000 % 10;
				int ww = num / 10000;
				if (gw == ww && sw == qw) {
					System.out.println(num+"是回文数");
				}else {
					System.out.println(num+"不是回文数");
				}
			}else {
				System.err.println("输入有误");
			}
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println("输入有错误");
		}finally {
			sc.close();
		}

	}

}

    原文作者:妖怪一样
    原文地址: https://blog.csdn.net/weixin_44032514/article/details/96569963
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞