VB输入整数N,显示出具有N行的"杨辉三角形".
PrivateSubCommand1_Click()DimA(N,N)AsIntegerN=Text1.TextDimA(N,N)Fori=1ToNForj=1ToiIf...
Private Sub Command1_Click()
Dim A(N, N) As IntegerN = Text1.TextDim A(N, N) For i = 1 To N For j = 1 To i If j = 1 Or i = j Then A(i, j) = 1 Else A(i, j) = A(i - 1, j - 1) + A(i - 1, j) End If Next j Next i For i = 1 To N For j = 1 To iPicture1.Print A(i, j); Next j Print Next i End Sub
帮我看一下矩阵转置好么?不会啊。。。
Private Sub Picture1_Click() Dim a(4, 4) As Integer, i As Integer, j As IntegerFor i = 1 To 4For j = 1 To 4a(i, j) = Int(Rnd() * 61 + 20)Picture1.Print a(i, j);NextPicture1.PrintNextPicture1.Print
End Sub 展开
Dim A(N, N) As IntegerN = Text1.TextDim A(N, N) For i = 1 To N For j = 1 To i If j = 1 Or i = j Then A(i, j) = 1 Else A(i, j) = A(i - 1, j - 1) + A(i - 1, j) End If Next j Next i For i = 1 To N For j = 1 To iPicture1.Print A(i, j); Next j Print Next i End Sub
帮我看一下矩阵转置好么?不会啊。。。
Private Sub Picture1_Click() Dim a(4, 4) As Integer, i As Integer, j As IntegerFor i = 1 To 4For j = 1 To 4a(i, j) = Int(Rnd() * 61 + 20)Picture1.Print a(i, j);NextPicture1.PrintNextPicture1.Print
End Sub 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim A() As Integer
N = Text1.Text
ReDim A(N, N)
For i = 1 To N
For j = 1 To i
If j = 1 Or i = j Then
A(i, j) = 1
Else
A(i, j) = A(i - 1, j - 1) + A(i - 1, j)
End If
Next j
Next i
For i = 1 To N
For j = 1 To i
Picture1.Print A(i, j);
Next j
Picture1.Print
Next i
End Sub
你这个式可只要改一下就可以用了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询