求JAVA语言的源代码参考...
求JAVA语言的源代码参考...
下列乘法算式中:每个汉字代表1个数字(1~9).相同的汉字代表相同的数字,不同的汉字代表不同的数字.
赛软件 * 比赛 = 软件比拼
试编程确定使得整个算式成立的数字组合,如有多种情况,请给出所有可能的答案.
【参考结果】
465 * 14 = 6510
每个汉字代表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);
}
}
}
}
}
}
}