Private Sub Form_Load() Me.Hide Open App.Path & "\out.txt" For Output As #1 x = 150000000000# i = 1 ans = 1 Do While i < x ans = ans + 1 i = i * 2 Loop Print #1, ans Close End End Sub
Private Sub Form_Load() Me.Hide Open App.Path & "/out.txt" For Output As #1 n = Val(150000000000#) i = 1 ans = 1 Do While n > i ans = ans + 1 i = i * 2 Loop Print #1, ans Close End End Sub
Private Sub Form_Load() Open App.Path & "\out.txt" For Output As #1 x = 1.5 * 10 ^ 11 i = 1 ans = 1 Do While i < x ans = ans + 1 i = i * 2 Loop Print #1, ans Close End End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\out.txt" For Output As #1
x = 150000000000#
i = 1
ans = 1
Do While i < x
ans = ans + 1
i = i * 2
Loop
Print #1, ans
Close
End
End Sub
Ans:39
作者已經移除這則留言。
回覆刪除Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "/out.txt" For Output As #1
n = Val(150000000000#)
i = 1
ans = 1
Do While n > i
ans = ans + 1
i = i * 2
Loop
Print #1, ans
Close
End
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\out.txt" For Output As #1
x = 1.5 * 10 ^ 11
i = 1
ans = 1
Do While i < x
ans = ans + 1
i = i * 2
Loop
Print #1, ans
Close
End
End Sub
小冰,晟晟,哲好,
回覆刪除三個程式都正確。
幾個小地方,
一,這個距離有些大,定義個長整數,會容易些。
二,乘法,除法是比較數的,用加法,是比較快的。i = i *2, i = i + i
(哦,突然想起,2進位中的乘以2,也是超快的啦。就是在尾端加個0,就是了。)
回覆刪除