给定一个五位数,判断是否为回文数。12321, 85258, 785587
郑州大学——徐峰
类:
public class Homework09 {
void test3 (int a){
int t,i,x=0,y;
y=a;
for(i=1;i<=5;i++){
t=a%10;
a=a/10;
x=x*10+t;
}
if(x==y){
System.out.println("该数是回文数");
}else{
System.out.println("该数不是回文数");
}
}
}
主方法:
import java.util.Scanner;
public class Main09 {
public static void main(String[] args){
Homework09 q= new Homework09();
Scanner s = new Scanner(System.in);
System.out.println("a=");
int a=s.nextInt();
q.test3(a);
}
}