vb 编程,回文

2025-02-01 11:43:41
推荐回答(1个)
回答1:

Function IsH(n) As Boolean
Dim s As String
s = CStr(n)
IsH = s = StrReverse(s)
End Function

Function IsH2(n) As Boolean 'Mid版
Dim s As String, i As Integer, k As Integer, rt As Boolean
s = CStr(n)
k = Len(s) \ 2
rt = True
For i = 1 To k
If Mid(s,i,1)<>Mid(s,k-i+1,1) = False Then

rt = False
Exit For
End If
Next
IsH2 = rt
End Function