[請益]巴斯卡三角形

看板Visual_Basic作者 (毅力)時間19年前 (2006/05/13 18:40), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
'顯示結果要對齊真難 Dim j As Integer Dim i As Integer Dim n As Integer Dim c1 As Double Dim c2 As Double Dim c3 As Double Private Sub Command1_Click() j = 1 n = InputBox("N層") Do Print Print Space(n * 3 - j * 2 - n * 1.2); '這邊的空格是用目測的 For i = 0 To j '要怎樣才能剛剛好? Call cxy(0, 0) c1 = cxy(j, j - i) Call cxy(0, 0) c2 = cxy(i, 0) c3 = c1 / c2 If c3 > 9 Then Print "" & c3; Else Print c3; End If Next j = j + 1 Loop Until j = n End Sub Function cxy(a As Integer, b As Integer) As Double If a > b Then cxy = cxy(a - 1, b) * a Else cxy = 1 End If End Function -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.231.58.120

05/13 20:28, , 1F
me.fontname="細明體"
05/13 20:28, 1F

05/14 10:53, , 2F
謝謝 我知道了
05/14 10:53, 2F
文章代碼(AID): #14PRUjct (Visual_Basic)
文章代碼(AID): #14PRUjct (Visual_Basic)