请教高手一个VB算法的问题

用VB写个算abcd*f=dcba,a,b,c,d,f为1到9的任意数,但不能重复请把代码写下,给分,谢谢!!!... 用VB写个算abcd*f=dcba,a,b,c,d,f为1到9的任意数,但不能重复
请把代码写下,给分,谢谢!!!
展开
 我来答
北京钢管中心
2009-06-21 · TA获得超过969个赞
知道小有建树答主
回答量:711
采纳率:0%
帮助的人:0
展开全部
Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double, d As Double, f As Double, m As Double, n As Double

For a = 1 To 9

For b = 1 To 9

For c = 1 To 9

For d = 1 To 9

For f = 1 To 9

m = (a * 1000 + b * 100 + c * 10 + d) * f
n = d * 1000 + c * 100 + b * 10 + a

If m = n And a <> b And a <> c And a <> d And b <> c And b <> d And c <> d Then
Print "a="; a, "b="; b, "c="; c, "d="; d
End If
Next f
Next d
Next c
Next b
Next a

End Sub

计算结果是:2178 f=4
沙瀑罗罗
2009-06-21 · TA获得超过230个赞
知道小有建树答主
回答量:253
采纳率:0%
帮助的人:163万
展开全部
做个循环就行吧。好麻烦啊
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
fangzhi0415
2009-06-21 · 超过13用户采纳过TA的回答
知道答主
回答量:40
采纳率:0%
帮助的人:36.4万
展开全部
Dim a, b, c, d, f As Integer

Private Sub Form_Load()
For a = 1 To 9
For b = 1 To 9
For c = 1 To 9
For d = 1 To 9
For f = 1 To 9
If a <> b And b <> c And a <> c And a <> d And b <> d And c <> d And a <> f And b <> f And c <> f And d <> f Then
If (1000 * a + 100 * b + 10 * c + d) * f = 1000 * d + 100 * c + 10 * b + a Then
Print a & b & c & d; "x"; f
End If
End If
Next f, d, c, b, a
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
CdPzh
2009-06-21 · TA获得超过3064个赞
知道小有建树答主
回答量:641
采纳率:0%
帮助的人:757万
展开全部
Private Sub Command1_Click()
For i = 1 To 4 'f不可能等于1,至少为2,故a至多为4
For j = 1 To 9
For k = 1 To 9
For m = 1 To 9
For n = 1 To 8
If i <> j And i <> k And i <> m And j <> k And j <> m And k <> m And n <> i _
And n <> j And n <> k And n <> m Then
a = (1000 * i + 100 * j + 10 * k + m) * n
b = 1000 * m + k * 100 + j * 10 + i
If a = b Then
Print i, j, k, m, n
Exit Sub
End If
End If
Next
Next
Next
Next
Next
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式