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
展开
 我来答
百度网友2ca1c0f24
推荐于2016-10-22 · TA获得超过2036个赞
知道大有可为答主
回答量:4364
采纳率:0%
帮助的人:3423万
展开全部
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
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式