用递归方法实现判回文字符串的函数。
#include
#include
#define M 80
//要求用递归方法实现该函数
bool isPalindrome(const char *s,int low,int high) {
//......
}
//函数isPalindrome被重载
bool isPalindrome(const char *s) {
return isPalindrome(s,0,strlen(s)-1);
}
int main() {
char s[M];
while (std::cin.getline(s,M)) {
if (isPalindrome(s))
std::cout<<'Y';
else
std::cout<<'N';
}
std::cout<<std::endl;
return 0;
}
输入
有n行,每行是一个长度不超过80的字符串
输出
n个YN组成的字符串,对应行的字符串是回文输出Y否则输出N