2个回答
展开全部
杨辉三角形就是用数组解决最方便。
只要能达到目的,有简单的为什么不用呢?你用数组编好上交,没问题的。
只打印前9行
先把form的autoredraw属性改成true,代码如下:
==========================
Option Explicit
Dim a(10, 10) As Long
Dim b(10) As String
Dim i As Byte
Dim j As Byte
Private Sub Form_Load()
a(0, 0) = 1
For i = 1 To 9
For j = 1 To 9
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
If a(i, j) <> 0 Then
b(j) = b(j - 1) & " " & a(i, j)
End If
Next
Print b(i)
Next
End Sub
只要能达到目的,有简单的为什么不用呢?你用数组编好上交,没问题的。
只打印前9行
先把form的autoredraw属性改成true,代码如下:
==========================
Option Explicit
Dim a(10, 10) As Long
Dim b(10) As String
Dim i As Byte
Dim j As Byte
Private Sub Form_Load()
a(0, 0) = 1
For i = 1 To 9
For j = 1 To 9
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
If a(i, j) <> 0 Then
b(j) = b(j - 1) & " " & a(i, j)
End If
Next
Print b(i)
Next
End Sub
参考资料: http://zhidao.baidu.com/question/7171528.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
xgbbg你真土啊!下面这段代码运行试试。
Private Sub Command1_Click()
Dim i As Long, j As Long, cnr As Long
Dim n As Integer
n = 7
Print 1
For i = 1 To n
cnr = 1
Print cnr;
For j = 1 To i
cnr = cnr * (i - j + 1) / j
Print cnr;
Next
Print
Next
End Sub
Private Sub Command1_Click()
Dim i As Long, j As Long, cnr As Long
Dim n As Integer
n = 7
Print 1
For i = 1 To n
cnr = 1
Print cnr;
For j = 1 To i
cnr = cnr * (i - j + 1) / j
Print cnr;
Next
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询