每个汉字代表1个数字(1~9)
那i后面参考结果中的0是哪里来的
如果是代表0到9的数字我这里写了一个应该算是本方法的方法
public static void main(String[] args) {
String[] sai = {"0","1","2","3","4","5","6","7","8","9"};
String[] ruan = {"0","1","2","3","4","5","6","7","8","9"};
String[] jian = {"0","1","2","3","4","5","6","7","8","9"};
String[] bi = {"0","1","2","3","4","5","6","7","8","9"};
String[] pin = {"0","1","2","3","4","5","6","7","8","9"};
for (String saii : sai) {
for (String ruani : ruan) {
if(ruani.equals(saii))
continue;
for (String jiani : jian) {
if(jiani.equals(ruani) || jiani.equals(saii))
continue;
for (String bii : bi) {
if(bii.equals(jiani) || bii.equals(ruani) || bii.equals(saii))
continue;
for (String pini : pin) {
if(pini.equals(bii) || pini.equals(jiani) || pini.equals(ruani) || pini.equals(saii)){
continue;
}
String tmp1=saii+ruani+jiani;
String tmp2=bii+saii;
String tmp3=ruani+jiani+bii+pini;
int tmpI1=Integer.parseInt(tmp1);
int tmpI2=Integer.parseInt(tmp2);
int tmpI3=Integer.parseInt(tmp3);
int tmpI4=tmpI1*tmpI2;
if(tmpI4==tmpI3){
System.out.println(tmp1+"*"+tmp2+"="+tmp3);
}
}
}
}
}
}
}