
杨辉三角如何用VB语言表示?
1个回答
展开全部
来个短一点的,呵呵。
Private Sub Form_click()
Cls
Dim a() As Single
n = Val(InputBox("请输入行数", "杨辉三角", 5))
ReDim a(n + 1, n + 1)
For i = 1 To n
For j = 1 To i
a(i, 1) = 1
a(i, i) = 1
a(i + 1, j + 1) = a(i, j) + a(i, j + 1)
Print a(i, j);
Next j
Print
Next i
End Sub
Private Sub Form_click()
Cls
Dim a() As Single
n = Val(InputBox("请输入行数", "杨辉三角", 5))
ReDim a(n + 1, n + 1)
For i = 1 To n
For j = 1 To i
a(i, 1) = 1
a(i, i) = 1
a(i + 1, j + 1) = a(i, j) + a(i, j + 1)
Print a(i, j);
Next j
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询