[Java] 纯文本查看 复制代码 import java.util.Scanner;
class AntiNum{
int EN,TNT,FT,BT;
boolean AR;
AntiNum(){
System.out.println("Please input the number");
Scanner t = new Scanner(System.in);
int a = t.nextInt();
this.EN=a;
this.compute();
this.result();
}
void result(){
if(AR == true){
System.out.println(EN+" is a Palindrome");
}else{
System.out.println(EN+" is not a Palindrome");
}
}
void compute(){
FT =1;
BT = this.getlength(EN);
Mark:
while(BT >= FT){
if(this.taste(FT) == this.taste(BT)){
AR = true;
FT++;
BT--;
}else{
AR = false;
break;
}
}
}
int taste(int a){
int b;
if(a == 1){
b = EN%miC(a);
}else{
b = (EN%miC(a) - EN%this.miC(a - 1)) / this.miC(a - 1);
}
return b;
}
int miC(int b){
int a = 10;
int c = a;
if(b <= 0){
a = 0;
}else{
for(int d = 2;d <= b;d++){
a = a * c;
}
}
return a;
}
int getlength(int a){
Integer a1 = a;
int b = a1.toString().length();
return b;
}
}
class NumTest{
public static void main(String[] args){
AntiNum test = new AntiNum();
}
}
|