从品牌网站建设到网络营销策划,从策略到执行的一站式服务
给你个参考:
成都创新互联为客户提供专业的网站建设、做网站、程序、域名、空间一条龙服务,提供基于WEB的系统开发. 服务项目涵盖了网页设计、网站程序开发、WEB系统开发、微信二次开发、移动网站建设等网站方面业务。
Private Sub hanoi(n As Integer, one As String, two As String, three As String)
If n = 1 Then
Print Tab(5); one; "-------"; three
Else
Call hanoi(n - 1, one, three, two)
Print Tab(5); one; "-------"; three
Call hanoi(n - 1, two, one, three)
End If
End Sub
Private Sub Form_Click()
Dim x As Integer
x = Val(InputBox("请输入圆盘的个数"))
Print Tab(5); "将" x "个圆盘从A柱移到C柱的移动顺序为"
Call hanoi(x, "A", "B", "C")
End Sub
private function Hnt(n as integer,A,as string,B as string,C as string)
Hnt (n-1),a,c,b
是上面的函数的四个参数呀,这是在函数中再次调用本函数
Dim N As Integer
Private Sub Form_Click()
Dim N As Integer
N = Val(InputBox("请输入汉诺塔的圆盘总数:"))
Call MoveDisk(N, "A", "B", "C")
End Sub
Sub MoveDisk(N, A As String, B As String, C As String)
If N = 1 Then
Print "将第1个圆盘从第" A "根柱子移到第" C "根柱子"
Else
Call MoveDisk(N - 1, A, C, B)
Print "将第" N "个圆盘从第" A "根柱子移到第" C "根柱子"
Call MoveDisk(N - 1, B, A, C)
End If
End Sub
这个是文字型的,你自己转换成图片的吧
dim ncont as double
private function Hnt(n as integer,A,as string,B as string,C as string)
ncont=ncont+1
if n1 then
Hnt (n-1),a,c,b
Hnt (n-1),b,a,c
end if
end function
private sub command1_click()
dim i as integer
dim a as string
dim b as string
dim c as string
i=7 '此值即为汉诺塔的阶数.计算超过12的汉诺塔会死机,
Hnt (i,a,b,c)
text1.text=ncont
end sub
运行结果:127
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图