📅  最后修改于: 2022-03-11 14:52:02.139000             🧑  作者: Mango
#include
#include
using namespace std;
bool isPolindrom(string s){
int len = s.length();
if (len < 2) return true; // if s == '' or s ==
bool condition = (s[0] == s[len-1]); // first symbol == last symbol
return condition && isPolindrom(s.substr(1, len-2)); // recursion
}
int main()
{
string name;
cout << "What is your word? ";
getline (cin, word);
cout << "it is" << (isPolindrom(word) ? " polindrom" : " not polindrom");
}