苏州硕宝科技:求程序!!!qbasic的

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 07:38:50
□□□*(□+□)+□□-□*□=2005 在□里填上1-9,使等式成立

教一个比较笨的方法,用循环一个一个数试,也就是穷举法!

Cls
Dim a,b,c,d,e,f,g as integer

For a = 100 to 999
for b=1 to 9
for c = 1 to 9
for d = 10 to 99
for e = 1 to 9
for f = 1 to 9
if ((a*(b+c) + d - e*f)= 2005) then
print a,b,c,d,e,f
end if
next f
next e
next d
next c
next b
next a
End