VB中求杨辉三角 下面这个哪里有问题呀
Dima()AsIntegerPrivateSubCommand1_Click()Picture1.Clsn=Val(Text1.Text)ReDima(n,n)Fori...
Dim a() As Integer
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If i = 1 Or j = i Then
a(i, j) = 1
Else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub 展开
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If i = 1 Or j = i Then
a(i, j) = 1
Else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub 展开
2个回答
展开全部
代码已经调试:
Dim a() As Integer
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If i = 1 Or j = i Then
a(i, j) = 1
Else
a(i, j) = a(i - 1, IIf(j > 0, j - 1, j)) + a(i - 1, j) '这里增加而来IIF
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub
Dim a() As Integer
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If i = 1 Or j = i Then
a(i, j) = 1
Else
a(i, j) = a(i - 1, IIf(j > 0, j - 1, j)) + a(i - 1, j) '这里增加而来IIF
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub
更多追问追答
追问
看不懂。。 a(i, j) = a(i - 1, IIf(j > 0, j - 1, j)) + a(i - 1, j) '这里增加而来IIF
a(i - 1, IIf(j > 0, j - 1, j))是 个什么呀
追答
var = IIf(j > 0, j - 1, j)相当于if分支语句
If j>0 then
var=j-1
Else
var=j
End if
武义菲亚伏电子有限公司
2023-06-12 广告
2023-06-12 广告
绝缘子控件是指:“一种能够在架空输电线路中起到重要作用的特殊绝缘控件,能够在架空输电线路中起到重要作用。”绝缘子的作用是支持和固定母线与带电导体,并使带电导体间或导体与大地之间有足够的距离和绝缘。绝缘子应具有足够的电气绝缘强度和耐潮湿性能。...
点击进入详情页
本回答由武义菲亚伏电子有限公司提供
展开全部
测试了一下,一点点小错
Dim a() As Integer
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If j = 0 Or j = i Then '错在这里不是i=1
a(i, j) = 1
Else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub
Dim a() As Integer
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
ReDim a(n, n)
For i = 0 To n
For j = 0 To i
If j = 0 Or j = i Then '错在这里不是i=1
a(i, j) = 1
Else
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
End If
Picture1.Print a(i, j);
Next
Picture1.Print
Next
End Sub
追问
恩 谢谢
那接着这个程序 把杨辉三角变成等腰三角形怎么变呀
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询