#include <iostream>
using namespace std;
bool PalinStr(string obj)
{
if (obj == "" || obj.length() == 1)return true;
else if (obj[0] == obj.back() && PalinStr(obj.substr(1, obj.length() - 2)))return true;
else return false;
}
bool palinstr(string obj) {
int strlen = obj.length();
bool ispalinstr = true;
if (strlen <= 1) {
return true;
}
for (int i = 0; i < strlen / 2; i++) {
if (obj[i] != obj[strlen - 1 - i]) {
ispalinstr = false;
break;
}
}
return ispalinstr;
}
int main() {
string tem;
tem = "abcba";
cout << "递归: ";
if (PalinStr(tem)) cout << "This string is true" << endl;
else cout << "This string is false" << endl;
cout << "递推: ";
if (palinstr(tem)) cout << "This string is true" << endl;
else cout << "This string is false" << endl;
return 0;
}