用java输出0-99999之间的三重回文数
付睿 2015-10-20 02:07:22 ps:只能显示出11然后就直接强退了。
import javax.swing.JOptionPane;
public class ProjectThree {
public static int Reverse(int x1){
int reverse = 0;
int[] m = new int[6];
int i = 0;
while (x1 != 0) {
i++;
m[i] = x1%10;
x1 = x1/10;
}
int j = i;
for(;i>=1;i--){
reverse += m[i]*Math.pow(10, j - i);
}
return reverse;
}
public static boolean IsPalindrome(int x1){
int num2 = Reverse(x1);
if (x1 == num2)
return true;
else
return false;
}
public static void main(String[]args){
for(int x=10;x<=99999;x++){
int x1 = (int) Math.pow(x, 2);
int x2 = (int) Math.pow(x, 3);
if(IsPalindrome(x)==true&&IsPalindrome(x1)==true&&IsPalindrome(x2)==true)
JOptionPane.showMessageDialog(null, x);
}
}
}