**Hey guys I'm new to c++ and I've been trying to get some practice with it.
我有这个方法来检查我是否要返回布尔的回文。我想递归地执行此操作。这个有输入吗?**
bool isPalindrome(std::string word)
{
if (word.length() == 0 || word.length() == 1)
{
return true;
}
else if (word.at(0) == word.at(word.length() - 1))
{
return isPalindrome(word.substr(1, word.length() - 1));
}
return false;
}
感谢大家对的帮助
bool isPalindrome(std::string word)
{
if (word.length() == 0 || word.length() == 1)
{
return true;
}
else if (word[0] == word.at(word.length() - 1))
{
return isPalindrome(word.substr(1, word.length() - 2));
}
return false;
}