Private Sub Command1_Click()
Cls
Dim x()
n = Val(InputBox(""))
ReDim x(n, n)
For i = 1 To n
  x(i, 1) = 1: x(i, i) = 1
Next i
For i = 2 To n
For j = 1 To i - 1
  x(i, j) = x(i - 1, j - 1) + x(i - 1, j)
Next j
Next i
For i = 1 To n
  Print String(5 * (n - i), " ");
For j = 1 To i
    s = ""
  For k = 5 - Len(LTrim(Str(x(i, j)))) To 1 Step -1
vb所有代码
    s = s & " "
  Next k
    s = s & LTrim(Str(x(i, j))) & String(5, " ")
    Print s;
Next j
Print
Next i
End Sub

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。