求VB6.0代码 在线等 -猜数字。设有算式...

来源:百度知道 编辑:UC知道 时间:2024/05/30 02:31:12
猜数字。设有算式:
A B C D
—)B A A C
__________
D D A

A,B,C,D均为非负非零的一位数字。算是中的ABCD及BAAC为四位数,DDA为三位数。 设计程序,找出满足以上算式的A,B,C及D
『提示』对四位数字的所有可能组合,检测以上算式是否成立,可用四重循环实现

课本原题
求代码
......ABCD
...—)BAAC
...._______
........DDA

前面是
Private Sub Form_Load()

dim strCombination(0 to 2) as string
for a = 1 to 9
for b= 1 to 9
for c = 0 to 9
for d = 1 to 9
strCombination(0)=cstr(a) & cstr(b) & cstr(c) & cstr(d)
strCombination(1)=cstr(b) & cstr(a) & cstr(a) & cstr(c)
strCombination(2)=cstr(d) & cstr(d) & cstr(a)
if val(strCombination(0))-val(strCombination(1))=val(strCombination(2)) then
debug.print "A:" & cstr(a)
debug.print "B:" & cstr(b)
debug.print "C:" & cstr(c)
debug.print "D:" & cstr(d)
exit for
end if
next
next
next
next