public class Excis4_10 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Search();
}
public static void Search(){
// int[] factor = new int[4];
int b = 0;
int a= 0;
boolean isMatched = false;
for( a=11;a<=99;){
a++;
for( b =11;b<=99;){
b++;
if((a*b>1000)&&(a*b<10000)){
isMatched = match(a,b);
}
if(isMatched){
System.out.println("这两个数是:"+a+"*"+b+"="+a*b);
}
else{
// System.out.println("这两个数不是吸血鬼数字");
}
}
}
}
private static boolean match(int a,int b) {
// TODO Auto-generated method stub
int mul = a*b;
int b_unit = b%10;
int b_ten = b/10;
int a_unit = a%10;
int a_ten = a/10;
int mul_thou = mul/1000;
int mul_hund = (mul-mul_thou*1000)/100;
int mul_ten = (mul-mul_thou*1000-mul_hund*100)/10;
int mul_unit = (mul-mul_thou*1000-mul_hund*100-mul_ten*10)%10;
int ab_factor[]={a_unit,a_ten,b_unit,b_ten};
int mul_factor[]={mul_unit,mul_ten,mul_hund,mul_thou};
boolean[] same = new boolean[4];
// boolean[] same_multoab = new boolean[4];
boolean isMatched = false;
for(int i= 0;i<4;i++)
for(int j= 0;j<4;j++){
if(ab_factor[i]==mul_factor[j]){
same[i] = true;
mul_factor[j] = -1;
}
}
// for(int i= 0;i<4;i++)
// for(int j= 0;j<4;j++){
// if(mul_factor[i]==ab_factor[j]){
// same_multoab[i] = true;
// mul_factor[i] = -1;
// }
//
// }
if(same[0]&&same[1]&&same[2]&&same[3]){
isMatched = true;
}
return isMatched;
}
}