📌  相关文章
📜  在线将 c++ 代码转换为 c - BASIC 代码示例

📅  最后修改于: 2022-03-11 14:52:02.139000             🧑  作者: Mango

代码示例10
#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"); 
}