VB 杨辉三角
输入n输出n+1层的杨辉三角而且要等腰的哪位高人帮我看看哪不对~~~谢啦!!!PrivateSubForm_Click()DimnAsInteger,iAsInteger...
输入n 输出n+1层的杨辉三角 而且要等腰的
哪位高人帮我看看哪不对~~~
谢啦!!!
Private Sub Form_Click()
Dim n As Integer, i As Integer, j As Integer
n = InputBox("请输入n")
ReDim a(n + 1, n + 1) As Integer
For i = 1 To n + 1
a(i, 1) = 1: a(i, i) = 1: Next i
For i = 3 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
Print Tab(30 - 2 * i);
For j = 1 To i
Print Space(4 - Len(Trim(Str(a(i, j))))); Trim(Str(a(i, j)));
Next j
Print
Next i
End Sub 展开
哪位高人帮我看看哪不对~~~
谢啦!!!
Private Sub Form_Click()
Dim n As Integer, i As Integer, j As Integer
n = InputBox("请输入n")
ReDim a(n + 1, n + 1) As Integer
For i = 1 To n + 1
a(i, 1) = 1: a(i, i) = 1: Next i
For i = 3 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
Print Tab(30 - 2 * i);
For j = 1 To i
Print Space(4 - Len(Trim(Str(a(i, j))))); Trim(Str(a(i, j)));
Next j
Next i
End Sub 展开
展开全部
Dim n As Integer, i As Integer, j As Integer
x = InputBox("请输入n")
n = Val(x)
ReDim a(n + 1, n + 1) As Integer
For i = 1 To n + 1
a(i, 1) = 1: a(i, i) = 1: Next i
For i = 3 To n + 1
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
Print Tab(30 - 2 * i);
For j = 1 To i
Print Space(4 - Len(Trim(Str(a(i, j))))); Trim(Str(a(i, j)));
Next j
Print
Next i
x = InputBox("请输入n")
n = Val(x)
ReDim a(n + 1, n + 1) As Integer
For i = 1 To n + 1
a(i, 1) = 1: a(i, i) = 1: Next i
For i = 3 To n + 1
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
Print Tab(30 - 2 * i);
For j = 1 To i
Print Space(4 - Len(Trim(Str(a(i, j))))); Trim(Str(a(i, j)));
Next j
Next i
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询