#include <iostream>
#include <string.h>
using namespace std;
bool huiwen(char*,int,int);
const int maxsize=80;
int main()
{
char str[80];
while(cin>>str)
{
if (huiwen(str,0,strlen(str)-1))
cout<<"1"<<endl;
else
cout<<"0"<<endl;
}
}
bool huiwen(char* s, int beg,int end)
{
if (beg>=end) return 1;
else
{
if(s[beg]!=s[end]) return 0;
else return huiwen(s,++beg,--end);
}
}
利用递归来实现回文数的判断
最新推荐文章于 2021-11-26 21:44:21 发布