2802: 判断字符串是否为回文
 
 时间限制: 1 Sec  
 内存限制: 128 MB
 
提交: 348  
 解决: 246
 
 
题目描述
 
编写程序,判断输入的一个字符串是否为回文。若是则输出“Yes”,否则输出“No”。所谓回文是指順读和倒读都是一样的字符串。
 
输入
 
 
输出
 
 
样例输入
abcddcba
样例输出
Yes
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
 
#include <iostream>
#include <string.h>
#include<stdio.h>
using namespace std;
int fun(int low,int high,char *str,int length)
{
if (length==0||length==1)return 1;
if (str[low]!=str[high])return 0;
return fun(low+1,high-1,str,length-2);
}
int main()
{
char str[200];
cin>>str;
int length=strlen(str);
if(fun(0,length-1,str,length))cout<<"Yes";
else cout<<"No";
return 0;
}
 










