Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Line Input #1, x x = Replace(x, " ", "*") If Len(x) Mod 8 <> 0 Then For i = 1 To 8 - (Len(x) Mod 8) x = x & "*" Next End If For j = 1 To Len(x) ans = ans & Mid(x, j, 1) If Len(ans) = 8 Then Print #2, ans ans = "" End If Next Close Close End End Sub
Private Sub Form_Load() Dim ans(10) As String Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x y = 1 For i = 1 To 8 For j = 1 To Len(x) \ 8 If Mid(x, y, 1) <> "*" Then ans(j) = ans(j) & Mid(x, y, 1) Else ans(j) = ans(j) & " " End If y = y + 1 Next Next For i = 1 To Len(x) \ 8 Print #2, ans(i); Next Close Close 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
Line Input #1, x
x = Replace(x, " ", "*")
If Len(x) Mod 8 <> 0 Then
For i = 1 To 8 - (Len(x) Mod 8)
x = x & "*"
Next
End If
For j = 1 To Len(x)
ans = ans & Mid(x, j, 1)
If Len(ans) = 8 Then
Print #2, ans
ans = ""
End If
Next
Close
Close
End
End Sub
解密的意思應該是輸出"The final contest for getting right"吧
回覆刪除Private Sub Form_Load()
回覆刪除Dim ans(10) As String
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
y = 1
For i = 1 To 8
For j = 1 To Len(x) \ 8
If Mid(x, y, 1) <> "*" Then
ans(j) = ans(j) & Mid(x, y, 1)
Else
ans(j) = ans(j) & " "
End If
y = y + 1
Next
Next
For i = 1 To Len(x) \ 8
Print #2, ans(i);
Next
Close
Close
End
End Sub
小冰好,
回覆刪除學長arro說的是對的。
你的程式也是對的。
那個判斷星號*的if是沒必要的,像前一次做的,用replace一次,就完成了。