用vb编写输出任意行数的杨辉三角的程序那里出错了?为什么? 5
PrivateSubText1_Change()Dimx()AsIntegern=Val(text1)ReDimx(n,n)x(1,1)=1:x(2,1)=1:x(2,2...
Private Sub Text1_Change()
Dim x() As Integer
n = Val(text1)
ReDim x(n, n)
x(1, 1) = 1: x(2, 1) = 1: x(2, 2) = 1
Picture1.Cls
Picture1.Print Tab(20); x(1, 1) = 1
Picture1.Print Tab(19); x(2, 1) = 1; x(2, 2) = 1
For i = 3 To n
Picture1.Print Tab(21 - i); x(1, 1);
For j = 2 To i - 1
x(i - 1, 1) = 1: x(i - 1, i - 1) = 1
x(i, j) = x(i - 1, j - 1) + x(i - 1, j)
Picture1.Print x(i, j);
Next
Picture1.Print x(i, i) = 1;
Picture1.Print
Next 展开
Dim x() As Integer
n = Val(text1)
ReDim x(n, n)
x(1, 1) = 1: x(2, 1) = 1: x(2, 2) = 1
Picture1.Cls
Picture1.Print Tab(20); x(1, 1) = 1
Picture1.Print Tab(19); x(2, 1) = 1; x(2, 2) = 1
For i = 3 To n
Picture1.Print Tab(21 - i); x(1, 1);
For j = 2 To i - 1
x(i - 1, 1) = 1: x(i - 1, i - 1) = 1
x(i, j) = x(i - 1, j - 1) + x(i - 1, j)
Picture1.Print x(i, j);
Next
Picture1.Print x(i, i) = 1;
Picture1.Print
Next 展开
3个回答
2012-11-23
展开全部
搞不清你的思路,杨辉三角用VB,仅仅是输出位置问题。
另外,用 Private Sub Text1_Change() 也没有道理,如果Text1比较大,程序就会死机。
另外,用 Private Sub Text1_Change() 也没有道理,如果Text1比较大,程序就会死机。
追问
我是在Text上输入相输出的行数,然后再Picture上显示输出结果。
追答
搞不清你的思路,杨辉三角用VB,仅仅是输出位置问题。
其他.......
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Text1_Change()
Dim x() As Integer
n = Val(Text1)
ReDim x(n, n)
x(1, 1) = 1: x(2, 1) = 1: x(2, 2) = 1
Picture1.Cls
Picture1.Print Tab(20); x(1, 1)
Picture1.Print Tab(19); x(2, 1); x(2, 2)
For i = 3 To n
Picture1.Print Tab(21 - i); x(1, 1);
For j = 2 To i - 1
x(i - 1, 1) = 1: x(i - 1, i - 1) = 1
x(i, j) = x(i - 1, j - 1) + x(i - 1, j)
Picture1.Print x(i, j);
Next
x(i, i) = 1
Picture1.Print x(i, i): Picture1.Print
Next
End Sub
Dim x() As Integer
n = Val(Text1)
ReDim x(n, n)
x(1, 1) = 1: x(2, 1) = 1: x(2, 2) = 1
Picture1.Cls
Picture1.Print Tab(20); x(1, 1)
Picture1.Print Tab(19); x(2, 1); x(2, 2)
For i = 3 To n
Picture1.Print Tab(21 - i); x(1, 1);
For j = 2 To i - 1
x(i - 1, 1) = 1: x(i - 1, i - 1) = 1
x(i, j) = x(i - 1, j - 1) + x(i - 1, j)
Picture1.Print x(i, j);
Next
x(i, i) = 1
Picture1.Print x(i, i): Picture1.Print
Next
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
end sub哪去了
追问
有 End sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询