VB编程:输入整数n,分别按直角三角形和等腰三角行显示n行杨辉三角
2个回答
展开全部
Private Sub Command1_Click()
Dim n%, i%, j%, a() As Integer
n = InputBox("多项式系数:", "输入框")
ReDim a(0 To n, 0 To n)
Cls
For i = 0 To n
a(i, 0) = 1
Next
Print a(0, 0)
For i = 1 To n
Print a(i, 0);
For j = 1 To i
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Print a(i, j);
Next
Print
Next
End Sub
Private Sub Command2_Click()
Dim n%, i%, j%, a() As Integer
n = InputBox("多项式系数:", "输入框")
ReDim a(0 To n, 0 To n)
Cls
For i = 0 To n
a(i, 0) = 1
Next
Print Tab(n + 20); a(0, 0)
For i = 1 To n
m = 0
c = c + 2
Print Tab(n + 20 - c); a(i, 0);
For j = 1 To i
m = m + 5
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Print Tab(n + 20 - c + m); a(i, j);
Next j
Print
Next i
End Sub
Dim n%, i%, j%, a() As Integer
n = InputBox("多项式系数:", "输入框")
ReDim a(0 To n, 0 To n)
Cls
For i = 0 To n
a(i, 0) = 1
Next
Print a(0, 0)
For i = 1 To n
Print a(i, 0);
For j = 1 To i
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Print a(i, j);
Next
Next
End Sub
Private Sub Command2_Click()
Dim n%, i%, j%, a() As Integer
n = InputBox("多项式系数:", "输入框")
ReDim a(0 To n, 0 To n)
Cls
For i = 0 To n
a(i, 0) = 1
Next
Print Tab(n + 20); a(0, 0)
For i = 1 To n
m = 0
c = c + 2
Print Tab(n + 20 - c); a(i, 0);
For j = 1 To i
m = m + 5
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Print Tab(n + 20 - c + m); a(i, j);
Next j
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
晕死 我不懂杨辉三角
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询