English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

約成最簡分數
例如:9/18變成1/2
怎麼用vb寫出來呀??

2006-06-21 13:58:28 · 1 個解答 · 發問者 佛萊迪 1 in 電腦與網際網路 程式設計

1 個解答

Private Sub Command1_Click()    Dim N As Long        '先找出最大公因數    N = GCD(9, 18)    '輸出    Print "9 / 18 ="; 9 / N; "/"; 18 / NEnd SubFunction GCD(ByVal A1 As Long, ByVal A2 As Long) As Long '最大公因數副函數    Dim T As Long        Do While A1 Mod A2      T = A1 Mod A2: A1 = A2: A2 = T    Loop    GCD = A2End Function

2006-06-21 14:25:35 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers