已经测试过,符合你的要求,代码如下:望采纳!
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class numberCom {
public static void main(String args[]) throws IOException{
//创建数据量对象
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入数字:");
//从键盘读取数据
int number =Integer.parseInt(br.readLine().trim());
numberCom n = new numberCom();
if(number==n.isPalindrome(number)){
System.out.println("是回文数");
}else{
System.out.println("不是回文数");
};
}
public int isPalindrome(int x){
String result = "";
int n = 10;
int y;
int z = 0;
for(int i=0;i<5;i++){
y = x%n-z;
z = z+y;
y = y*10/n;
result = result+y;
n = n*10;
}
return Integer.parseInt(result);
}
}
作业自己做