import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int b = num; //保留原数字,避免后面num做除法被削为0
int n = String.valueOf(num).length();
String a = ""; //创建一个空字符串,储存num倒序输出的数字
for (int i=0; i<n; i++){
a += num % 10;
num = num / 10; //这里对num做除法,最后变成0
}
int number = Integer.parseInt(a);
if(b==number){
System.out.println(n+"\nY");
}
else{
System.out.println(n+"\nN");
}
}
}
PTA java 判断回文数
最新推荐文章于 2024-11-04 20:33:37 发布