做一个VB屏幕中显示9行杨辉三角
求个程序,formload后,单击使程序中显示一个金字塔型的杨辉三角(显示到第9行)~要金字塔型的不要直角三角型那样的哦~...
求个程序,formload后,单击使程序中显示一个金字塔型的杨辉三角(显示到第9行)~要金字塔型的不要直角三角型那样的哦~
展开
2个回答
展开全部
Dim A() As Integer
Private Sub Form_Click()
N = InputBox("请输入n")
ReDim A(1 To N, 1 To N)
Cls
For I = 1 To N
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) + A(I - 1, J - 1)
Next J, I
For I = 1 To N
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
输入9就是9行的
Private Sub Form_Click()
N = InputBox("请输入n")
ReDim A(1 To N, 1 To N)
Cls
For I = 1 To N
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) + A(I - 1, J - 1)
Next J, I
For I = 1 To N
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
输入9就是9行的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询