VB中判断是否为回文数的function过程,求教我自己写的哪里错了

2025-01-04 03:36:18
推荐回答(2个)
回答1:

Function foundhuiwen(p As String) As Boolean
'考生编写
Dim ResultValue As Boolean
Dim i As Long
Dim s As Long
i = 1
s = Len(p)
ResultValue = True
Do While i <= s \ 2
If Mid(p, i, 1) = Mid(p, s - i + 1, 1) Then '此处是S,而不是n
i = i + 1
Else
ResultValue = False
Exit Do
End If
Loop
foundhuiwen = ResultValue
End Function

回答2:

s=Len(p)之前加2行
dim i as integer
i=1

你说有问题的那句,式中的n改成s(哪来的n呢)

最后一句判断 if i>p\2,将p改成s

粗心的学生。