用VB做一个程序题目是这样的:输入行数显示该行数的杨辉三角
2013-05-28
Private Sub Form_Click() '能输出20行以下的
Dim a()
Dim n As Integer
Me.AutoRedraw = True
Cls
n = Val(InputBox(" 请你输入行数!"))
If n >= 1 And n <= 20 Then
ReDim a(1 To n, 1 To n)
For i = 1 To n
For j = 1 To n
If i = j Or j = 1 Then a(i, j) = 1
Next j
Next i
For i = 1 To n
For j = 1 To i
If j <> 1 And i <> j Then
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
Print Tab(j * 2 * (3 + n / 8) - i * (3 + n / 8) + 15 * (1 + n / 3)); a(i, j);
Next j
Print
Next i
End If
End Sub
这 段代码 什么意思啊
嗯解释下么 谢谢啊