Private Sub Form_Load() Me.Hide Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Output As #2 Dim i, g, k As Integer Dim h(99) i = 0 k = 0 Input #1, g
If g > 16 Then Do While g > 16 k = k + 1 i = i + 1 h(i) = g Mod 16 g = g \ 16 Loop End If
If g = 10 Then g = "A": If g = 11 Then g = "B" If g = 12 Then g = "C": If g = 13 Then g = "D" If g = 14 Then g = "E": If g = 15 Then g = "F"
For x = 1 To k If h(x) = 10 Then h(x) = "A": If h(x) = 11 Then h(x) = "B" If h(x) = 12 Then h(x) = "C": If h(x) = 13 Then h(x) = "D" If h(x) = 14 Then h(x) = "E": If h(x) = 15 Then h(x) = "F" Next
Private Sub Form_Load() Me.Hide Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Output As #2 Dim i, k As Integer Dim h(99), g i = 0 k = 0 Input #1, g
If g > 16 Then Do While g > 16 k = k + 1 i = i + 1 h(i) = g Mod 16 g = g \ 16 Loop End If
If g = 10 Then g = "A" If g = 11 Then g = "B" If g = 12 Then g = "C" If g = 13 Then g = "D" If g = 14 Then g = "E" If g = 15 Then g = "F"
For x = 1 To k If h(x) = 10 Then h(x) = "A" If h(x) = 11 Then h(x) = "B" If h(x) = 12 Then h(x) = "C" If h(x) = 13 Then h(x) = "D" If h(x) = 14 Then h(x) = "E" If h(x) = 15 Then h(x) = "F" Next
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Dim z As String Input #1, x Do y = x Mod 16 Select Case y Case 10 a = "A" Case 11 a = "B" Case 12 a = "C" Case 13 a = "D" Case 14 a = "E" Case 15 a = "F" Case Else a = y End Select x = x \ 16 z = a & z Loop Until x = 0 Print #2, z Close #2 Close #1 End End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Output As #2
Dim i, g, k As Integer
Dim h(99)
i = 0
k = 0
Input #1, g
If g > 16 Then
Do While g > 16
k = k + 1
i = i + 1
h(i) = g Mod 16
g = g \ 16
Loop
End If
If g = 10 Then g = "A": If g = 11 Then g = "B"
If g = 12 Then g = "C": If g = 13 Then g = "D"
If g = 14 Then g = "E": If g = 15 Then g = "F"
For x = 1 To k
If h(x) = 10 Then h(x) = "A": If h(x) = 11 Then h(x) = "B"
If h(x) = 12 Then h(x) = "C": If h(x) = 13 Then h(x) = "D"
If h(x) = 14 Then h(x) = "E": If h(x) = 15 Then h(x) = "F"
Next
Print #2, g & "";
For y = i To 1 Step -1
Print #2, h(y) & "";
Next
Close
Close
End
End Sub
小冰程式有錯噢
回覆刪除你輸入15
正確應為F 你答案是 15
很多語法還沒完全了解該如何使用
回覆刪除就很容易出錯誤了
Private Sub Form_Load()
Me.Hide
Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Output As #2
Dim i, k As Integer
Dim h(99), g
i = 0
k = 0
Input #1, g
If g > 16 Then
Do While g > 16
k = k + 1
i = i + 1
h(i) = g Mod 16
g = g \ 16
Loop
End If
If g = 10 Then g = "A"
If g = 11 Then g = "B"
If g = 12 Then g = "C"
If g = 13 Then g = "D"
If g = 14 Then g = "E"
If g = 15 Then g = "F"
For x = 1 To k
If h(x) = 10 Then h(x) = "A"
If h(x) = 11 Then h(x) = "B"
If h(x) = 12 Then h(x) = "C"
If h(x) = 13 Then h(x) = "D"
If h(x) = 14 Then h(x) = "E"
If h(x) = 15 Then h(x) = "F"
Next
Print #2, g & "";
For y = i To 1 Step -1
Print #2, h(y) & "";
Next
Close
Close
End
End Sub
程式對了。
回覆刪除下次嘗試 select case 吧
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Dim z As String
Input #1, x
Do
y = x Mod 16
Select Case y
Case 10
a = "A"
Case 11
a = "B"
Case 12
a = "C"
Case 13
a = "D"
Case 14
a = "E"
Case 15
a = "F"
Case Else
a = y
End Select
x = x \ 16
z = a & z
Loop Until x = 0
Print #2, z
Close #2
Close #1
End
End Sub
哲好,
回覆刪除程式正確。
還可以更進階哦。
用字串"0123456789ABCDEF" 直接分成陣列,
再將餘數直接指向陣列中的相應位置,
可以試試哦。
(其實我是在感冒中啦,所以在巴黎的公寓中沒出門)