﻿ JAVA中如何实现吸血鬼数字 - JAVA 教程

# JAVA中如何实现吸血鬼数字

2017-11-01 08:00 星期三 所属： JAVA 教程 浏览：61

```public class Practice {
public static void Fun() {
int x=1000;
while(x<10000) {
int d,c,b,a;
a = x/1000;//千分
b = (x/100)%10;//百分位
c = (x/10)%10;//十分位
d = x%10;//个位
if(c!=0 || d!=0) {
if(x == (a*10+b)*(c*10+d)) {
System.out.println(x);
x++;
continue;
}
if(x == (a*10+b)*(d*10+c)) {
System.out.println(x);
x++;
continue;
}
if(x == (b*10+a)*(c*10+d)) {
System.out.println(x);
x++;
continue;
}
if(x == (b*10+a)*(d*10+c)) {
System.out.println(x);
x++;
continue;
}
if(x == (a*10+c)*(b*10+d)) {
System.out.println(x);
x++;
continue;
}
if(x == (a*10+c)*(b*10+d)) {
System.out.println(x);
x++;
continue;
}
if(x == (c*10+a)*(b*10+d)) {
System.out.println(x);
x++;
continue;
}
if(x == (c*10+a)*(d*10+b)) {
System.out.println(x);
x++;
continue;
}
if(x == (a*10+d)*(c*10+b)) {
System.out.println(x);
x++;
continue;
}
if(x == (a*10+d)*(b*10+c)) {
System.out.println(x);
x++;
continue;
}
if(x == (d*10+a)*(c*10+b)) {
System.out.println(x);
x++;
continue;
}
if(x == (d*10+a)*(b*10+c)) {
System.out.println(x);
x++;
continue;
}
}
x++;
}
}
public static void main(String[] args){
Fun();
}
}```

0 (0 票)