📄 杨辉三角,对称.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 6840
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 6840
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
Height = 2415
Left = 1320
ScaleHeight = 2355
ScaleWidth = 3915
TabIndex = 0
Top = 240
Width = 3975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub picture1_Click()
n = Val(InputBox("请输入行数", "杨辉三角"))
ReDim a(n, n)
For i = 1 To n
a(i, 1) = 1: a(i, i) = 1
Next i
For i = 3 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j
Next i
For i = 1 To n
Picture1.Print Tab(14 - i);
For j = 1 To i
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -