package lianxi; import java.util.*; public class Huiwenshu { public static void main(String[] args) { System.out.println("输入一个5位的正整数"); Scanner shu=new Scanner(System.in); String a=shu.next(); String b=""; for (int i = a.length()-1; i >= 0; i--) { b=b+a.substring(i,i+1); } //System.out.println(b); if(a.equals(b)) { System.out.println("输入的是回文数"); } else { System.out.println("输入的不是回文数"); } } }
时间: 2024-11-05 02:17:25