VB编程打印输出杨辉三角?
打印效果如图:111121133114641我明明是输入的三角形的杨辉三角,怎么变成那个样子啊,请大家请谅等边三角形的杨辉三角哟....
打印效果如图: 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
我明明是输入的三角形的杨辉三角,怎么变成那个样子啊,请大家请谅
等边三角形的杨辉三角哟. 展开
1 1
1 2 1
1 3 3 1
1 4 6 4 1
我明明是输入的三角形的杨辉三角,怎么变成那个样子啊,请大家请谅
等边三角形的杨辉三角哟. 展开
1个回答
展开全部
Option Explicit
Dim a(21, 21) As Long
Dim b(21) As String
Dim i As Byte
Dim j As Byte
Private Sub Form_Load()
a(0, 0) = 1
For i = 1 To 20
For j = 1 To 20
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
Dim a(21, 21) As Long
Dim b(21) As String
Dim i As Byte
Dim j As Byte
Private Sub Form_Load()
a(0, 0) = 1
For i = 1 To 20
For j = 1 To 20
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询