帮忙编写这个程序的VB代码

来源:百度知道 编辑:UC知道 时间:2024/05/12 19:44:47
要求a,b,c,d,e,f,g,h,i,j为0到9之间的整数且a+bc+def=ghij
将满足条件的所有结果以及结果的数目输出
晕 这么简单的题目难道没有高手帮忙么 出个简单的

Dim a,b,c,d,e,f,g,h,i,j as Integer

Private Sub Form_Load()
for a = 0 to 9
for b = 0 to 9
for c = 0 to 9
for d = 0 to 9
for e = 0 to 9
for f = 0 to 9
for g = 0 to 9
for h = 0 to 9
for i = 0 to 9
for j = 0 to 9
if a+b*c+d*e*f=g*h*i*j then
print a,b,c,d,e,f,g,h,i,j
num=num+1
end if
if a=b=c=d=e=f=g=h=i=j=9 then
print "有" & num & "个"
end if
next
next
next
next
next
next
next
next
next
next

穷举法,但机子会很卡,解很多~~~ 窗体根本print 不下
把字母弄少点吧~~

Option Explicit
Dim a,b,c,d,e,f,g,h,i as Integer

Private Sub Form_Load()
For a = 0 to 9
For b = 0 to 9
For c = 0 to 9
For d = 0 to 9
For e = 0 to 9
For f = 0 to 9
For g = 0 to 9
For h = 0 to 9
For i = 0 to 9
For j = 0 to 9
If a+b*10+c+d*100+e*10+f=g*100+h*10+i*+j Then
Print a,b,c,