回覆列表
  • 1 # 滴逃逃

    Private Sub Command1_Click()

    Dim a() As Long

    Dim n As Integer, v

    Dim i As Integer, j As Integer

    v = InputBox("請輸入楊輝三角的行數")

    If IsNumeric(v) = False Or Len(v) = 0 Then

    MsgBox ("輸入不是數字或者為空,請重新輸入!")

    Else

    n = v

    End If

    ReDim a(n, n)

    For i = 1 To n

    For j = 1 To i

    If j = 1 Or i = j Then

    a(i, j) = 1

    Else

    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(n * 3 - 3 * i + 6 * j); a(i, j);

    Next j

    Next i

    End Sub

  • 中秋節和大豐收的關聯?
  • 格力3匹空調主機尺寸是多少?