'迴文判斷
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rStr = ""
Dim n() = {"12321", "1", "1221", "123454321", "12312", "12"}
For m As Integer = 0 To UBound(n)
Dim i = Int(Len(n(m)) / 2) + 1
Dim isTrue = True
Dim j = 1
Dim k = Len(n(m))
While j < i
If Mid(n(m), j, 1) <> Mid(n(m), k, 1) Then isTrue = False
j = j + 1
k = k - 1
End While
rStr = rStr & n(m) & ":" & IIf(isTrue, "迴文", "非迴文") & vbNewLine
Next
MsgBox(rStr)
End Sub
End Class
沒有留言:
張貼留言