2 回答
TA贡献1856条经验 获得超11个赞
Function Check(ByVal str As String) As Boolean
Dim re As Boolean = True
Dim length As Integer
length = str.Length
Dim mid As Integer
mid = Math.Floor(length / 2)
Dim i As Integer = 0
Dim j As Integer = 0
Dim k As Integer = 0
Dim firstStr As String
Dim lastStr As String
If length Mod 2 <> 0 Then
For i = 0 To mid
j = i
k = mid * 2 - i
firstStr = str(j)
lastStr = str(k)
If firstStr <> lastStr Then
re = False
Exit For
End If
Next
Else
re = False
End If
Return re
End Function
TA贡献1851条经验 获得超4个赞
vb的语法忘了,我用.net些吧
char[] ch=str.ToChar();
bool b=false;
if(ch.length\2!=0)
{
for(int i=0;i<=(ch.length-1)/2;i++)
{
if(ch[i]==ch[ch.length-1-i])
{
b=true;
continue;
}
else
{
b=false;
break;
}
}
return b;
}
- 2 回答
- 0 关注
- 252 浏览
添加回答
举报