编辑代码

#include<iostream>
using namespace std;
bool f(const char* str,int strlen)   //递归
{
	if(strlen<=1)
	return true;
	if(str[0]==str[strlen-1]){
	
	return f(str+1,strlen-2);}
	return false;
 } 

bool F(char * str,int strlen)   //递推
{

    for(int i=0;i<strlen/2;i++)
    {
        if(str[i]!=str[strlen-i-1])
        {
            return false;
        }
    }
    return true;
}

 int main()
 {
   char str[]="acba";
   int strlen=4;
   if(f(str,strlen))
   {
   cout<<"是回文"; 
    }
   else 
   {
   cout<<"不是回文"; }
   cout<<endl;
   if(F(str,strlen))
   {
   cout<<"是回文"; 
    }
   else 
   {
   cout<<"不是回文"; }
   return 0;
 }