第8章-数组精要
【例8-7】编写程序输出杨辉三角. 杨辉三角的特点: 第一列元素为1 第二行元素为1 对角线的元素都为1 其他元素:a(i,j)=a(i-1,j-1)+a(i-1,j) Private Sub Form_Load() Frame1.Caption = 请输入一个整数: Label1.Caption = 输入一个整数n,并按回车键, 即可求得杨辉三角形的前n项 Text1.Text = End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim n As Integer, a() As Integer If KeyAscii = 13 Then n = Val(Text1.Text) If n 16 Then MsgBox 输入的数不能超过16 Exit Sub End If ReDim a(n, n) For i = 1 To n a(i, 1) = 1: a(i, i) = 1 Next p = Format(1, !@@@@) Chr(13) 第一行 p = p Format(1, !@@@@) Format(
原创力文档

文档评论(0)