isPalidrome()函数检测一个字符串是否为回文字符串。这里区分字母的大小写。
bool isPalindrome(const char *s)
{
int len = strlen(s);
const char *tmp = s + len - 1;
while(tmp > s)
{
//把此句改为 if(*tmp != *s && toupper(*tmp) != toupper(*s)) 即可不区分大小写
if(*tmp != *s)
{
return false;
}
s++;
tmp--;
}
return true;
}