用vb.net2008打印杨辉三角形(打印10行),要求如图所示

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/24 17:28:21
用vb.net2008打印杨辉三角形(打印10行),要求如图所示
xSAo0+VT;idj'uHLv]-V . q#5Nhi!}v1lnbdgc"8l^;NN.f_~IjߕLp5J)9Ry d)mzR&۶Y=bg<Y4/z<ı pZ>vƻA=RH1qCP5F L]ǎpE. "{@zr C:Ov+/R[z Ša(UR"X3ҋڮ|HvS<O܏!ax8LK#vGRTɱ143~I6>l3!i7+X-U\媏=>B?uYj^ fy(( 'LcCML_5T/>7UYN^d|=b'͊WGS8ZCj׭Jnli++HqP߼\z)|ލOLutjLQQ^0:)mZkcJ5s/B}{\^g/L

用vb.net2008打印杨辉三角形(打印10行),要求如图所示
用vb.net2008打印杨辉三角形(打印10行),要求如图所示


用vb.net2008打印杨辉三角形(打印10行),要求如图所示
Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim n As Integer, i As Integer, j As Integer, a(,) As Integer
n = 10
ReDim a(n + 1, n + 1)
For i = 1 To n + 1
a(i, 1) = 1 : a(i, i) = 1 : Next i
For i = 3 To n + 1
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
For j = 1 To i
TextBox1.AppendText(Space(4 - Len(Trim(Str(a(i, j))))) & Trim(Str(a(i, j))))
Next j
TextBox1.AppendText(vbCrLf)
Next i
End Sub
End Class